Last change
on this file since 13661 was 12304, checked in by michael2402, 7 years ago |
Javadoc for public methods / classes in gui.util and gui.widgets
|
-
Property svn:eol-style
set to
native
|
File size:
990 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.widgets;
|
---|
3 |
|
---|
4 | import javax.swing.Action;
|
---|
5 | import javax.swing.JList;
|
---|
6 | import javax.swing.JMenuItem;
|
---|
7 | import javax.swing.JPopupMenu;
|
---|
8 | import javax.swing.event.ListSelectionListener;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * A popup menu for one or more lists. If actions are added to this menu, a ListSelectionListener is registered automatically.
|
---|
12 | * @author Vincent
|
---|
13 | */
|
---|
14 | public class ListPopupMenu extends JPopupMenu {
|
---|
15 |
|
---|
16 | private final JList<?>[] lists;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Create a new ListPopupMenu
|
---|
20 | * @param lists The lists to which listeners should be appended
|
---|
21 | */
|
---|
22 | public ListPopupMenu(JList<?>... lists) {
|
---|
23 | this.lists = lists;
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | public JMenuItem add(Action a) {
|
---|
28 | if (lists != null && a instanceof ListSelectionListener) {
|
---|
29 | for (JList<?> list : lists) {
|
---|
30 | list.addListSelectionListener((ListSelectionListener) a);
|
---|
31 | }
|
---|
32 | }
|
---|
33 | return super.add(a);
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.