Class PopupWindow


  • public class PopupWindow
    extends java.lang.Object
    PopupWindow class

    You can add another JPopupMenu or JComboxBox in this popup.

    This class is copied from http://forum.java.sun.com/thread.jsp?forum=57&thread=230866 with some minor modifications.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.swing.event.EventListenerList listenerList
      A list of event listeners for this component.
    • Constructor Summary

      Constructors 
      Constructor Description
      PopupWindow​(java.awt.Container container)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.awt.Component component)  
      void addAsExcludedComponents​(java.awt.Component comp)
      PopupWindow will add necessary listeners to some components so that mouse click etc can hide the popup window.
      void addPopupMenuListener​(javax.swing.event.PopupMenuListener l)
      Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.
      void firePopupMenuCanceled()
      Notifies PopupMenuListeners that the popup portion of the combo box has been canceled.
      void firePopupMenuWillBecomeInvisible()
      Notifies PopupMenuListeners that the popup portion of the combo box has become invisible.
      void firePopupMenuWillBecomeVisible()
      Notifies PopupMenuListeners that the popup portion of the combo box will become visible.
      javax.swing.event.PopupMenuListener[] getPopupMenuListeners()
      Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().
      void hide()  
      boolean isExcludedComponent​(java.awt.Component comp)  
      boolean isVisible()
      Gets the visibility of this popup.
      void removeFromExcludedComponents​(java.awt.Component comp)  
      void removePopupMenuListener​(javax.swing.event.PopupMenuListener l)
      Removes a PopupMenuListener.
      void show​(java.awt.Component relative, int x, int y)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • listenerList

        protected javax.swing.event.EventListenerList listenerList
        A list of event listeners for this component.
    • Constructor Detail

      • PopupWindow

        public PopupWindow​(java.awt.Container container)
    • Method Detail

      • add

        public void add​(java.awt.Component component)
      • show

        public void show​(java.awt.Component relative,
                         int x,
                         int y)
      • hide

        public void hide()
      • isVisible

        public boolean isVisible()
        Gets the visibility of this popup.
        Returns:
        true if popup is visible
      • addPopupMenuListener

        public void addPopupMenuListener​(javax.swing.event.PopupMenuListener l)
        Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box.

        For all standard look and feels shipped with Java 2, the popup list portion of combo box is implemented as a JPopupMenu. A custom look and feel may not implement it this way and will therefore not receive the notification.

        Parameters:
        l - the PopupMenuListener to add
        Since:
        1.4
      • getPopupMenuListeners

        public javax.swing.event.PopupMenuListener[] getPopupMenuListeners()
        Returns an array of all the PopupMenuListeners added to this JComboBox with addPopupMenuListener().
        Returns:
        all of the PopupMenuListeners added or an empty array if no listeners have been added
        Since:
        1.4
      • firePopupMenuWillBecomeVisible

        public void firePopupMenuWillBecomeVisible()
        Notifies PopupMenuListeners that the popup portion of the combo box will become visible.

        This method is public but should not be called by anything other than the UI delegate.

        Since:
        1.4
        See Also:
        addPopupMenuListener(javax.swing.event.PopupMenuListener)
      • firePopupMenuWillBecomeInvisible

        public void firePopupMenuWillBecomeInvisible()
        Notifies PopupMenuListeners that the popup portion of the combo box has become invisible.

        This method is public but should not be called by anything other than the UI delegate.

        Since:
        1.4
        See Also:
        addPopupMenuListener(javax.swing.event.PopupMenuListener)
      • firePopupMenuCanceled

        public void firePopupMenuCanceled()
        Notifies PopupMenuListeners that the popup portion of the combo box has been canceled.

        This method is public but should not be called by anything other than the UI delegate.

        Since:
        1.4
        See Also:
        addPopupMenuListener(javax.swing.event.PopupMenuListener)
      • addAsExcludedComponents

        public void addAsExcludedComponents​(java.awt.Component comp)
        PopupWindow will add necessary listeners to some components so that mouse click etc can hide the popup window. However in certain case, you might not want this.
        Parameters:
        comp - component which will not hide popup when it is clicked.
      • removeFromExcludedComponents

        public void removeFromExcludedComponents​(java.awt.Component comp)
      • isExcludedComponent

        public boolean isExcludedComponent​(java.awt.Component comp)