Class PDropDown

All Implemented Interfaces:
ActionListener, MouseListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, SwingConstants

public class PDropDown extends JButton implements ActionListener, MouseListener
A drop-down menu similar to a combo-box. The big difference is when a menu item is selected the label for the menu does not change. Registering an ActionListener on this component will result in a callback with the JMenuItem that was selected from the popup menu. The caller does not need to register an ActionListener with each JMenuItem themselves.
Version:
%version: 9 % %date_modified: Thu Oct 04 13:37:39 2001 %
Author:
kapono
See Also:
  • Constructor Details

    • PDropDown

      public PDropDown()
      Creates a new PDropDown menu with an empty label
    • PDropDown

      public PDropDown(String label)
      Creates a new PDropDown menu with the given label
      Parameters:
      label -
    • PDropDown

      public PDropDown(String label, JMenuItem[] data)
      Creates a new PDropDown menu with the given label and containing the given JMenuItems.
      Parameters:
      label - The menu label
      data - The contents of the popup menu
    • PDropDown

      public PDropDown(String label, JPopupMenu menu)
      Creates a new PDropDown menu with the given label and uses the given JPopupMenu. This is useful if separators are to be used in the popup menu.
      Parameters:
      label - The menu label
      menu - The popup menu
  • Method Details

    • setData

      public void setData(JMenuItem[] mi)
      Establishes new menu contents
      Parameters:
      mi - The new menuitems to display in the popup
    • getData

      public JMenuItem[] getData()
      Retrieves the popup menu contents
      Returns:
      The array of JMenuItems that comprise the popup menu
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Internal callback for menu selection events
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - The action event
    • mouseEntered

      public void mouseEntered(MouseEvent me)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent me)
      Specified by:
      mouseExited in interface MouseListener
    • mouseClicked

      public void mouseClicked(MouseEvent me)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent me)
      Specified by:
      mouseReleased in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent me)
      Specified by:
      mousePressed in interface MouseListener
    • fireActionPerformed

      protected void fireActionPerformed(ActionEvent event)
      This is a no-op to eliminate the standard button action events
      Overrides:
      fireActionPerformed in class AbstractButton
    • _fireActionPerformed

      protected void _fireActionPerformed(ActionEvent event)
      Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.