jdk/src/share/classes/javax/swing/PopupFactory.java
changeset 2496 c0dfcd9b27f7
parent 1301 15e81207e1f2
child 5506 202f599c92aa
equal deleted inserted replaced
2495:3e32bdf43a35 2496:c0dfcd9b27f7
   550          */
   550          */
   551         boolean fitsOnScreen() {
   551         boolean fitsOnScreen() {
   552             boolean result = false;
   552             boolean result = false;
   553             Component component = getComponent();
   553             Component component = getComponent();
   554             if (owner != null && component != null) {
   554             if (owner != null && component != null) {
   555                 Container parent = (Container) SwingUtilities.getRoot(owner);
       
   556                 int popupWidth = component.getWidth();
   555                 int popupWidth = component.getWidth();
   557                 int popupHeight = component.getHeight();
   556                 int popupHeight = component.getHeight();
   558                 Rectangle parentBounds = parent.getBounds();
   557 
       
   558                 Container parent = (Container) SwingUtilities.getRoot(owner);
   559                 if (parent instanceof JFrame ||
   559                 if (parent instanceof JFrame ||
   560                     parent instanceof JDialog ||
   560                     parent instanceof JDialog ||
   561                     parent instanceof JWindow) {
   561                     parent instanceof JWindow) {
   562 
   562 
       
   563                     Rectangle parentBounds = parent.getBounds();
   563                     Insets i = parent.getInsets();
   564                     Insets i = parent.getInsets();
   564                     parentBounds.x += i.left;
   565                     parentBounds.x += i.left;
   565                     parentBounds.y += i.top;
   566                     parentBounds.y += i.top;
   566                     parentBounds.width -= i.left + i.right;
   567                     parentBounds.width -= i.left + i.right;
   567                     parentBounds.height -= i.top + i.bottom;
   568                     parentBounds.height -= i.top + i.bottom;
   575                     } else {
   576                     } else {
   576                         result = parentBounds
   577                         result = parentBounds
   577                                 .contains(x, y, popupWidth, popupHeight);
   578                                 .contains(x, y, popupWidth, popupHeight);
   578                     }
   579                     }
   579                 } else if (parent instanceof JApplet) {
   580                 } else if (parent instanceof JApplet) {
       
   581                     Rectangle parentBounds = parent.getBounds();
   580                     Point p = parent.getLocationOnScreen();
   582                     Point p = parent.getLocationOnScreen();
   581                     parentBounds.x = p.x;
   583                     parentBounds.x = p.x;
   582                     parentBounds.y = p.y;
   584                     parentBounds.y = p.y;
   583                     result = parentBounds
   585                     result = parentBounds.contains(x, y, popupWidth, popupHeight);
   584                             .contains(x, y, popupWidth, popupHeight);
       
   585                 }
   586                 }
   586             }
   587             }
   587             return result;
   588             return result;
   588         }
   589         }
   589 
   590