Class PopupList<T>

All Implemented Interfaces:
KeyListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, MenuElement

public class PopupList<T> extends JPopupMenu implements KeyListener, MouseListener
A popup window that has a JList instead of menu items.
See Also:
  • Constructor Details

    • PopupList

      public PopupList(JComponent aComponent)
      Creates a new popup list.
    • PopupList

      public PopupList(JComponent aComponent, T[] theItems)
      Creates a new popup list with given items.
  • Method Details

    • getJList

      public JList getJList()
      Returns the JList.
    • createJList

      protected JList createJList()
      Creates the JList.
    • initJList

      protected void initJList(JList aList)
      Initializes the JList.
    • setItems

      public void setItems(T[] theItems)
      Sets items.
    • getSelectedItem

      public T getSelectedItem()
      Returns the currently selected JList item.
    • selectUp

      public void selectUp()
      Select up.
    • selectDown

      public void selectDown()
      Select down.
    • getItemText

      protected String getItemText(T anItem)
      Returns the text to use for list item.
    • getItemIcon

      protected Icon getItemIcon(T anItem)
      Returns the icon to use list item.
    • fireAction

      protected void fireAction(InputEvent anEvent)
      Called when user hits return or double-clicks.
    • setPreferredSize

      public void setPreferredSize(Dimension aSize)
      Override to store requested preferred size.
      Overrides:
      setPreferredSize in class JComponent
    • show

      public void show(Component invoker, int x, int y)
      Override to resize PopupMenu window if it won't fit on screen.
      Overrides:
      show in class JPopupMenu
    • setVisible

      public void setVisible(boolean b)
      Override to add/remove Component KeyListener.
      Overrides:
      setVisible in class JPopupMenu
    • keyTyped

      public void keyTyped(KeyEvent e)
      KeyListener Method to consume Arrow Up/Down, Enter and Escape.
      Specified by:
      keyTyped in interface KeyListener
    • keyPressed

      public void keyPressed(KeyEvent e)
      KeyListener Method to consume Arrow Up/Down, Enter and Escape.
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      KeyListener Method to consume Arrow Up/Down, Enter and Escape.
      Specified by:
      keyReleased in interface KeyListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      MouseListener methods.
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

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

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

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener