List of usage examples for javax.swing JList setComponentPopupMenu
@BeanProperty(preferred = true, description = "Popup to show") public void setComponentPopupMenu(JPopupMenu popup)
JPopupMenu
for this JComponent
. From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new JMenuItem("One")); popupMenu.add(new JMenuItem("Two")); popupMenu.add(new JMenuItem("Three")); JList<String> list = new JList<>( new String[] { "Hello", "World", "Something", "Else", "Out", "Of", "Ideas" }); list.setComponentPopupMenu(popupMenu); f.add(list);/*from w w w.j a v a 2 s . c om*/ f.pack(); f.setVisible(true); }