diff options
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java')
-rw-r--r-- | libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java | 95 |
1 files changed, 78 insertions, 17 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java index f6cbeec8879..7ec3aa074bd 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java @@ -38,10 +38,13 @@ exception statement from your version. */ package javax.swing.plaf.basic; +import gnu.classpath.NotImplementedException; + import java.awt.AWTEvent; import java.awt.Color; import java.awt.Component; import java.awt.Container; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Insets; @@ -164,6 +167,12 @@ public class BasicInternalFrameUI extends InternalFrameUI protected class BorderListener extends MouseInputAdapter implements SwingConstants { + /** + * If true, the cursor is being already shown in the alternative "resize" + * shape. + */ + transient boolean showingResizeCursor; + /** FIXME: Use for something. */ protected final int RESIZE_NONE = 0; @@ -255,7 +264,7 @@ public class BasicInternalFrameUI extends InternalFrameUI else if (e.getSource() == titlePane) { Rectangle fBounds = frame.getBounds(); - + frame.putClientProperty("bufferedDragging", Boolean.TRUE); dm.dragFrame(frame, e.getX() - xOffset + b.x, e.getY() - yOffset + b.y); } @@ -263,25 +272,69 @@ public class BasicInternalFrameUI extends InternalFrameUI /** * This method is called when the mouse exits the JInternalFrame. - * + * * @param e The MouseEvent. */ public void mouseExited(MouseEvent e) { - // There is nothing to do when the mouse exits - // the border area. + // Reset the cursor shape. + if (showingResizeCursor) + { + frame.setCursor(Cursor.getDefaultCursor()); + showingResizeCursor = false; + } } /** - * This method is called when the mouse is moved inside the - * JInternalFrame. - * + * This method is called when the mouse is moved inside the JInternalFrame. + * * @param e The MouseEvent. */ public void mouseMoved(MouseEvent e) { - // There is nothing to do when the mouse moves - // over the border area. + // Turn off the resize cursor if we are in the frame header. + if (showingResizeCursor && e.getSource() != frame) + { + frame.setCursor(Cursor.getDefaultCursor()); + showingResizeCursor = false; + } + else if (e.getSource()==frame && frame.isResizable()) + { + int cursor; + switch (sectionOfClick(e.getX(), e.getY())) + { + case NORTH: + cursor = Cursor.N_RESIZE_CURSOR; + break; + case NORTH_EAST: + cursor = Cursor.NE_RESIZE_CURSOR; + break; + case EAST: + cursor = Cursor.E_RESIZE_CURSOR; + break; + case SOUTH_EAST: + cursor = Cursor.SE_RESIZE_CURSOR; + break; + case SOUTH: + cursor = Cursor.S_RESIZE_CURSOR; + break; + case SOUTH_WEST: + cursor = Cursor.SW_RESIZE_CURSOR; + break; + case WEST: + cursor = Cursor.W_RESIZE_CURSOR; + break; + case NORTH_WEST: + cursor = Cursor.NW_RESIZE_CURSOR; + break; + default: + cursor = Cursor.DEFAULT_CURSOR; + } + + Cursor resize = Cursor.getPredefinedCursor(cursor); + frame.setCursor(resize); + showingResizeCursor = true; + } } /** @@ -326,7 +379,10 @@ public class BasicInternalFrameUI extends InternalFrameUI if (e.getSource() == frame && frame.isResizable()) dm.endResizingFrame(frame); else if (e.getSource() == titlePane) - dm.endDraggingFrame(frame); + { + dm.endDraggingFrame(frame); + frame.putClientProperty("bufferedDragging", null); + } } /** @@ -1119,12 +1175,8 @@ public class BasicInternalFrameUI extends InternalFrameUI installComponents(); installKeyboardActions(); - ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(false); if (! frame.isSelected()) - frame.getRootPane().getGlassPane().setVisible(true); - - frame.setOpaque(true); - frame.invalidate(); + frame.getGlassPane().setVisible(true); } } @@ -1140,9 +1192,7 @@ public class BasicInternalFrameUI extends InternalFrameUI uninstallListeners(); uninstallDefaults(); - ((JComponent) frame.getRootPane().getGlassPane()).setOpaque(true); frame.getRootPane().getGlassPane().setVisible(false); - frame = null; } @@ -1155,12 +1205,22 @@ public class BasicInternalFrameUI extends InternalFrameUI frame.setLayout(internalFrameLayout); LookAndFeel.installBorder(frame, "InternalFrame.border"); frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon")); + + // Let the content pane inherit the background color from its + // frame by setting the background to null. + Component contentPane = frame.getContentPane(); + if (contentPane != null + && contentPane.getBackground() instanceof UIResource) + { + contentPane.setBackground(null); + } } /** * This method installs the keyboard actions for the JInternalFrame. */ protected void installKeyboardActions() + throws NotImplementedException { // FIXME: Implement. } @@ -1243,6 +1303,7 @@ public class BasicInternalFrameUI extends InternalFrameUI * This method uninstalls the keyboard actions for the JInternalFrame. */ protected void uninstallKeyboardActions() + throws NotImplementedException { // FIXME: Implement. } |