classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Swing popup menu stuff reworked


From: Roman Kennke
Subject: [cp-patches] FYI: Swing popup menu stuff reworked
Date: Tue, 25 Oct 2005 13:55:27 +0000

Hi,

I reworked some bits in Swing that have to do with the JPopupMenu so the
JPopupMenu uses the popup support provided by
javax.swing.Popup(Factory). We previously did use a completely
independent (but similar) framework inside JPopupMenu. The reason for
this probably was that the Popup(Factory) stuff did not work at all. I
fixed this and some other issues with the attached patch.

I modified some methods in JPopupMenu so that they are executed on the
event queue, in order to avoid some synchronization problems with layout
managers. Theoretically we could remove the synchronization on the
BoxLayout that I added yesterday. However, I am not sure about this. It
is still possible that an application thread calls
JComponent.getPreferredSize() which calls into the layout manager. If
the event thread is inside a layout at this moment, this could still
lead to unexpected NPEs. Any opinions on that?

2005-10-24  Roman Kennke  <address@hidden>

        * javax/swing/JLayeredPane.java
        (addImpl): Removed unnecessary repaint() and revalidate() calls.
        * javax/swing/JPopupMenu.java
        (remove): Removed unnecessary revalidate() call.
        (insert): Removed code that installs GridBagConstraints.
JPopupMenu
        uses a BoxLayout and this is not needed anymore.
        (pack): Send this method call to the event queue to avoid
        synchronization problems. Set size to preferredSize of this menu.
        (setVisible): Send this method call to the event queue to avoid
        synchronization problems. Use PopupFactory for creating a popup.
        (setLocation): Use int fields instead of a Point field.
        (Popup): Removed inner interface. We use javax.swing.Popup now.
        (LightweightPopup): Likewise.
        (MediumWeightPopup): Likewise.
        (HeavyWeightPopup): Likewise.
        * javax/swing/Popup.java
        (JWindowPopup.JWindowPopup): Add contents to contentPane of
window.
        Set focusableWindowState to false.
        (JWindowPopup.show): Set size of window here.
        (LightweightPopup): New inner class.
        * javax/swing/PopupFactory.java
        (getPopup): Return heavyweight or lightweight popup depending on
        the parameters.
        * javax/swing/plaf/basic/BasicMenuItemUI.java
        (PropertyChangeHandler): Removed unneeded inner class.
        (BasicMenuItemUI): Removed instantiation of PropertyChangeHandler.
        (installListeners): Removed handling of the PropertyChangeHandler.
        (uninstallListeners): Removed handling of the
PropertyChangeHandler.
        * javax/swing/plaf/basic/BasicMenuUI.java
        (getMaximumSize): Don't treat popup menus different.

Attachment: Swing-Menus.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]