diff options
author | Lillian Angel <langel@redhat.com> | 2005-11-04 18:47:44 +0000 |
---|---|---|
committer | Lillian Angel <langel@redhat.com> | 2005-11-04 18:47:44 +0000 |
commit | 86885b30d7991cfbc6a4bdda801c32e14adb9f9b (patch) | |
tree | 998c3f65d0c1f53965e19bbe75f6787c33acb064 /javax | |
parent | 33f0da3cda03bdaa572f70c0cb81ea260ca4f01f (diff) | |
download | classpath-86885b30d7991cfbc6a4bdda801c32e14adb9f9b.tar.gz |
2005-11-04 Lillian Angel <langel@redhat.com>
* javax/swing/plaf/basic/BasicMenuItemUI.java
(paintMenuItem): Changed to use isTopLevelMenu rather than checking
instance of parent.
* javax/swing/plaf/basic/BasicPopupMenuUI.java
(popupMenuWillBecomeInvisible): Added check to prevent NPE.
* javax/swing/Popup.java:
Added new private field.
(LightweightPopup): Initialized layeredPane.
(show): Removed unneeded code.
(hide): Likewise.
Diffstat (limited to 'javax')
-rw-r--r-- | javax/swing/Popup.java | 15 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicMenuItemUI.java | 5 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicPopupMenuUI.java | 35 |
3 files changed, 31 insertions, 24 deletions
diff --git a/javax/swing/Popup.java b/javax/swing/Popup.java index 5b2615d2f..d7e89b5ae 100644 --- a/javax/swing/Popup.java +++ b/javax/swing/Popup.java @@ -224,7 +224,12 @@ public class Popup * The panel that holds the content. */ private JPanel panel; - + + /** + * The layered pane of the owner. + */ + private JLayeredPane layeredPane; + /** * Constructs a new <code>LightweightPopup</code> given its owner, * contents and the screen position where the popup @@ -252,6 +257,10 @@ public class Popup this.contents = contents; this.x = x; this.y = y; + + JRootPane rootPane = SwingUtilities.getRootPane(owner); + JLayeredPane layeredPane = rootPane.getLayeredPane(); + this.layeredPane = layeredPane; } /** @@ -260,8 +269,6 @@ public class Popup */ public void show() { - JRootPane rootPane = SwingUtilities.getRootPane(owner); - JLayeredPane layeredPane = rootPane.getLayeredPane(); // We insert a JPanel between the layered pane and the contents so we // can fiddle with the setLocation() method without disturbing a // JPopupMenu (which overrides setLocation in an unusual manner). @@ -282,8 +289,6 @@ public class Popup */ public void hide() { - JRootPane rootPane = SwingUtilities.getRootPane(owner); - JLayeredPane layeredPane = rootPane.getLayeredPane(); layeredPane.remove(panel); } } diff --git a/javax/swing/plaf/basic/BasicMenuItemUI.java b/javax/swing/plaf/basic/BasicMenuItemUI.java index db2ac24d3..9357050d2 100644 --- a/javax/swing/plaf/basic/BasicMenuItemUI.java +++ b/javax/swing/plaf/basic/BasicMenuItemUI.java @@ -350,10 +350,9 @@ public class BasicMenuItemUI extends MenuItemUI if (arrowIcon != null && (c instanceof JMenu)) { - Component parent = m.getParent(); - if (parent instanceof JPopupMenu) + if (!((JMenu) c).isTopLevelMenu()) // It is a MenuItem - d.width += arrowIcon.getIconWidth() + parent.getWidth(); + d.width += arrowIcon.getIconWidth() + m.getParent().getWidth(); else // It is a Menu, no arrowIcon painted. d.width += MenuGap; diff --git a/javax/swing/plaf/basic/BasicPopupMenuUI.java b/javax/swing/plaf/basic/BasicPopupMenuUI.java index 46bcd3679..e15a17bab 100644 --- a/javax/swing/plaf/basic/BasicPopupMenuUI.java +++ b/javax/swing/plaf/basic/BasicPopupMenuUI.java @@ -273,23 +273,26 @@ public class BasicPopupMenuUI extends PopupMenuUI RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities .getRoot(invoker); - ((Container) rootContainer).removeComponentListener(topWindowListener); - - // If this popup menu is the last popup menu visible on the screen, then - // stop interrupting mouse events in the glass pane before hiding this - // last popup menu. - boolean topLevelMenu = (popupMenu.getInvoker() instanceof JMenu) - && ((JMenu) popupMenu.getInvoker()) - .isTopLevelMenu(); - - if (topLevelMenu || ! (popupMenu.getInvoker() instanceof MenuElement)) + if (rootContainer != null) { - // set glass pane not to interrupt mouse events and remove - // mouseInputListener - Container glassPane = (Container) rootContainer.getGlassPane(); - glassPane.setVisible(false); - glassPane.removeMouseListener(mouseInputListener); - mouseInputListener = null; + ((Container) rootContainer).removeComponentListener(topWindowListener); + + // If this popup menu is the last popup menu visible on the screen, + // then + // stop interrupting mouse events in the glass pane before hiding this + // last popup menu. + boolean topLevelMenu = (popupMenu.getInvoker() instanceof JMenu) + && ((JMenu) popupMenu.getInvoker()).isTopLevelMenu(); + + if (topLevelMenu || !(popupMenu.getInvoker() instanceof MenuElement)) + { + // set glass pane not to interrupt mouse events and remove + // mouseInputListener + Container glassPane = (Container) rootContainer.getGlassPane(); + glassPane.setVisible(false); + glassPane.removeMouseListener(mouseInputListener); + mouseInputListener = null; + } } } |