< prev index next >

src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java

Print this page
rev 1580 : 6727661: Code improvement and warnings removing from the swing/plaf packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: alexp
Contributed-by: Florian Brunner <fbrunnerlist@gmx.ch>


 303       propertyChangeListener = null;
 304       borderListener = null;
 305     }
 306 
 307     protected void uninstallKeyboardActions(){
 308         if (internalFrameListener != null) {
 309             frame.removeInternalFrameListener(internalFrameListener);
 310         }
 311         internalFrameListener = null;
 312 
 313         SwingUtilities.replaceUIInputMap(frame, JComponent.
 314                                          WHEN_IN_FOCUSED_WINDOW, null);
 315         SwingUtilities.replaceUIActionMap(frame, null);
 316 
 317     }
 318 
 319     void updateFrameCursor() {
 320         if (resizing) {
 321             return;
 322         }
 323         Cursor s = (Cursor)frame.getLastCursor();
 324         if (s == null) {
 325             s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
 326         }
 327         frame.setCursor(s);
 328     }
 329 
 330     protected LayoutManager createLayoutManager(){
 331         return getHandler();
 332     }
 333 
 334     protected PropertyChangeListener createPropertyChangeListener(){
 335         return getHandler();
 336     }
 337 
 338 
 339 
 340     public Dimension getPreferredSize(JComponent x)    {
 341         if((JComponent)frame == x)
 342             return frame.getLayout().preferredLayoutSize(x);
 343         return new Dimension(100, 100);
 344     }
 345 
 346     public Dimension getMinimumSize(JComponent x)  {
 347         if((JComponent)frame == x) {
 348             return frame.getLayout().minimumLayoutSize(x);
 349         }
 350         return new Dimension(0, 0);
 351     }
 352 
 353     public Dimension getMaximumSize(JComponent x) {
 354         return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
 355     }
 356 
 357 
 358 
 359     /**
 360       * Installs necessary mouse handlers on <code>newPane</code>
 361       * and adds it to the frame.
 362       * Reverse process for the <code>currentPane</code>.
 363       */
 364     protected void replacePane(JComponent currentPane, JComponent newPane) {
 365         if(currentPane != null) {
 366             deinstallMouseHandlers(currentPane);
 367             frame.remove(currentPane);


1078                         frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
1079                     else
1080                         frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
1081                 }
1082                 else
1083                     updateFrameCursor();
1084                 return;
1085             }
1086 
1087             updateFrameCursor();
1088         }
1089 
1090         public void mouseEntered(MouseEvent e)    {
1091             updateFrameCursor();
1092         }
1093 
1094         public void mouseExited(MouseEvent e)    {
1095             updateFrameCursor();
1096         }
1097 
1098     };    /// End BorderListener Class
1099 
1100     protected class ComponentHandler implements ComponentListener {
1101       // NOTE: This class exists only for backward compatability. All
1102       // its functionality has been moved into Handler. If you need to add
1103       // new functionality add it to the Handler, but make sure this
1104       // class calls into the Handler.
1105       /** Invoked when a JInternalFrame's parent's size changes. */
1106       public void componentResized(ComponentEvent e) {
1107           getHandler().componentResized(e);
1108       }
1109 
1110       public void componentMoved(ComponentEvent e) {
1111           getHandler().componentMoved(e);
1112       }
1113       public void componentShown(ComponentEvent e) {
1114           getHandler().componentShown(e);
1115       }
1116       public void componentHidden(ComponentEvent e) {
1117           getHandler().componentHidden(e);
1118       }


1181       }
1182 
1183       public void internalFrameIconified(InternalFrameEvent e) {
1184           getHandler().internalFrameIconified(e);
1185       }
1186 
1187       public void internalFrameDeiconified(InternalFrameEvent e) {
1188           getHandler().internalFrameDeiconified(e);
1189       }
1190 
1191       public void internalFrameActivated(InternalFrameEvent e) {
1192           getHandler().internalFrameActivated(e);
1193       }
1194 
1195 
1196       public void internalFrameDeactivated(InternalFrameEvent e) {
1197           getHandler().internalFrameDeactivated(e);
1198       }
1199     }
1200 
1201     private static boolean isDragging = false;
1202     private class Handler implements ComponentListener, InternalFrameListener,
1203             LayoutManager, MouseInputListener, PropertyChangeListener,
1204             WindowFocusListener, SwingConstants {
1205 
1206         public void windowGainedFocus(WindowEvent e) {
1207         }
1208 
1209         public void windowLostFocus(WindowEvent e) {
1210             // Cancel a resize which may be in progress, when a
1211             // WINDOW_LOST_FOCUS event occurs, which may be
1212             // caused by an Alt-Tab or a modal dialog popup.
1213             cancelResize();
1214         }
1215 
1216         // ComponentHandler methods
1217         /** Invoked when a JInternalFrame's parent's size changes. */
1218         public void componentResized(ComponentEvent e) {
1219             // Get the JInternalFrame's parent container size
1220             Rectangle parentNewBounds = ((Component) e.getSource()).getBounds();
1221             JInternalFrame.JDesktopIcon icon = null;


1367             if(getWestPane() != null) {
1368                 Dimension size = getWestPane().getPreferredSize();
1369                 getWestPane().setBounds(cx, cy, size.width, ch);
1370                 cw -= size.width;
1371                 cx += size.width;
1372             }
1373 
1374             if(getEastPane() != null) {
1375                 Dimension size = getEastPane().getPreferredSize();
1376                 getEastPane().setBounds(cw - size.width, cy, size.width, ch);
1377                 cw -= size.width;
1378             }
1379 
1380             if(frame.getRootPane() != null) {
1381                 frame.getRootPane().setBounds(cx, cy, cw, ch);
1382             }
1383         }
1384 
1385 
1386         // MouseInputListener
1387         private Component mouseEventTarget = null;
1388         private Component dragSource = null;
1389 
1390         public void mousePressed(MouseEvent e) { }
1391 
1392         public void mouseEntered(MouseEvent e) { }
1393 
1394         public void mouseMoved(MouseEvent e) { }
1395 
1396         public void mouseExited(MouseEvent e) { }
1397 
1398         public void mouseClicked(MouseEvent e) { }
1399 
1400         public void mouseReleased(MouseEvent e) { }
1401 
1402         public void mouseDragged(MouseEvent e) { }
1403 
1404         // PropertyChangeListener
1405         public void propertyChange(PropertyChangeEvent evt) {
1406             String prop = (String)evt.getPropertyName();
1407             JInternalFrame f = (JInternalFrame)evt.getSource();
1408             Object newValue = evt.getNewValue();
1409             Object oldValue = evt.getOldValue();
1410 
1411             if (JInternalFrame.IS_CLOSED_PROPERTY == prop) {
1412                 if (newValue == Boolean.TRUE) {
1413                     // Cancel a resize in progress if the internal frame
1414                     // gets a setClosed(true) or dispose().
1415                     cancelResize();
1416                     if ((frame.getParent() != null) && componentListenerAdded) {
1417                         frame.getParent().removeComponentListener(
1418                                 componentListener);
1419                     }
1420                     closeFrame(f);
1421                 }
1422             } else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) {
1423                 if(newValue == Boolean.TRUE) {
1424                     maximizeFrame(f);
1425                 } else {
1426                     minimizeFrame(f);




 303       propertyChangeListener = null;
 304       borderListener = null;
 305     }
 306 
 307     protected void uninstallKeyboardActions(){
 308         if (internalFrameListener != null) {
 309             frame.removeInternalFrameListener(internalFrameListener);
 310         }
 311         internalFrameListener = null;
 312 
 313         SwingUtilities.replaceUIInputMap(frame, JComponent.
 314                                          WHEN_IN_FOCUSED_WINDOW, null);
 315         SwingUtilities.replaceUIActionMap(frame, null);
 316 
 317     }
 318 
 319     void updateFrameCursor() {
 320         if (resizing) {
 321             return;
 322         }
 323         Cursor s = frame.getLastCursor();
 324         if (s == null) {
 325             s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
 326         }
 327         frame.setCursor(s);
 328     }
 329 
 330     protected LayoutManager createLayoutManager(){
 331         return getHandler();
 332     }
 333 
 334     protected PropertyChangeListener createPropertyChangeListener(){
 335         return getHandler();
 336     }
 337 
 338 
 339 
 340     public Dimension getPreferredSize(JComponent x)    {
 341         if(frame == x)
 342             return frame.getLayout().preferredLayoutSize(x);
 343         return new Dimension(100, 100);
 344     }
 345 
 346     public Dimension getMinimumSize(JComponent x)  {
 347         if(frame == x) {
 348             return frame.getLayout().minimumLayoutSize(x);
 349         }
 350         return new Dimension(0, 0);
 351     }
 352 
 353     public Dimension getMaximumSize(JComponent x) {
 354         return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
 355     }
 356 
 357 
 358 
 359     /**
 360       * Installs necessary mouse handlers on <code>newPane</code>
 361       * and adds it to the frame.
 362       * Reverse process for the <code>currentPane</code>.
 363       */
 364     protected void replacePane(JComponent currentPane, JComponent newPane) {
 365         if(currentPane != null) {
 366             deinstallMouseHandlers(currentPane);
 367             frame.remove(currentPane);


1078                         frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
1079                     else
1080                         frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
1081                 }
1082                 else
1083                     updateFrameCursor();
1084                 return;
1085             }
1086 
1087             updateFrameCursor();
1088         }
1089 
1090         public void mouseEntered(MouseEvent e)    {
1091             updateFrameCursor();
1092         }
1093 
1094         public void mouseExited(MouseEvent e)    {
1095             updateFrameCursor();
1096         }
1097 
1098     }    /// End BorderListener Class
1099 
1100     protected class ComponentHandler implements ComponentListener {
1101       // NOTE: This class exists only for backward compatability. All
1102       // its functionality has been moved into Handler. If you need to add
1103       // new functionality add it to the Handler, but make sure this
1104       // class calls into the Handler.
1105       /** Invoked when a JInternalFrame's parent's size changes. */
1106       public void componentResized(ComponentEvent e) {
1107           getHandler().componentResized(e);
1108       }
1109 
1110       public void componentMoved(ComponentEvent e) {
1111           getHandler().componentMoved(e);
1112       }
1113       public void componentShown(ComponentEvent e) {
1114           getHandler().componentShown(e);
1115       }
1116       public void componentHidden(ComponentEvent e) {
1117           getHandler().componentHidden(e);
1118       }


1181       }
1182 
1183       public void internalFrameIconified(InternalFrameEvent e) {
1184           getHandler().internalFrameIconified(e);
1185       }
1186 
1187       public void internalFrameDeiconified(InternalFrameEvent e) {
1188           getHandler().internalFrameDeiconified(e);
1189       }
1190 
1191       public void internalFrameActivated(InternalFrameEvent e) {
1192           getHandler().internalFrameActivated(e);
1193       }
1194 
1195 
1196       public void internalFrameDeactivated(InternalFrameEvent e) {
1197           getHandler().internalFrameDeactivated(e);
1198       }
1199     }
1200 

1201     private class Handler implements ComponentListener, InternalFrameListener,
1202             LayoutManager, MouseInputListener, PropertyChangeListener,
1203             WindowFocusListener, SwingConstants {
1204 
1205         public void windowGainedFocus(WindowEvent e) {
1206         }
1207 
1208         public void windowLostFocus(WindowEvent e) {
1209             // Cancel a resize which may be in progress, when a
1210             // WINDOW_LOST_FOCUS event occurs, which may be
1211             // caused by an Alt-Tab or a modal dialog popup.
1212             cancelResize();
1213         }
1214 
1215         // ComponentHandler methods
1216         /** Invoked when a JInternalFrame's parent's size changes. */
1217         public void componentResized(ComponentEvent e) {
1218             // Get the JInternalFrame's parent container size
1219             Rectangle parentNewBounds = ((Component) e.getSource()).getBounds();
1220             JInternalFrame.JDesktopIcon icon = null;


1366             if(getWestPane() != null) {
1367                 Dimension size = getWestPane().getPreferredSize();
1368                 getWestPane().setBounds(cx, cy, size.width, ch);
1369                 cw -= size.width;
1370                 cx += size.width;
1371             }
1372 
1373             if(getEastPane() != null) {
1374                 Dimension size = getEastPane().getPreferredSize();
1375                 getEastPane().setBounds(cw - size.width, cy, size.width, ch);
1376                 cw -= size.width;
1377             }
1378 
1379             if(frame.getRootPane() != null) {
1380                 frame.getRootPane().setBounds(cx, cy, cw, ch);
1381             }
1382         }
1383 
1384 
1385         // MouseInputListener



1386         public void mousePressed(MouseEvent e) { }
1387 
1388         public void mouseEntered(MouseEvent e) { }
1389 
1390         public void mouseMoved(MouseEvent e) { }
1391 
1392         public void mouseExited(MouseEvent e) { }
1393 
1394         public void mouseClicked(MouseEvent e) { }
1395 
1396         public void mouseReleased(MouseEvent e) { }
1397 
1398         public void mouseDragged(MouseEvent e) { }
1399 
1400         // PropertyChangeListener
1401         public void propertyChange(PropertyChangeEvent evt) {
1402             String prop = evt.getPropertyName();
1403             JInternalFrame f = (JInternalFrame)evt.getSource();
1404             Object newValue = evt.getNewValue();
1405             Object oldValue = evt.getOldValue();
1406 
1407             if (JInternalFrame.IS_CLOSED_PROPERTY == prop) {
1408                 if (newValue == Boolean.TRUE) {
1409                     // Cancel a resize in progress if the internal frame
1410                     // gets a setClosed(true) or dispose().
1411                     cancelResize();
1412                     if ((frame.getParent() != null) && componentListenerAdded) {
1413                         frame.getParent().removeComponentListener(
1414                                 componentListener);
1415                     }
1416                     closeFrame(f);
1417                 }
1418             } else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) {
1419                 if(newValue == Boolean.TRUE) {
1420                     maximizeFrame(f);
1421                 } else {
1422                     minimizeFrame(f);


< prev index next >