Last change
on this file since 4848 was 4459, checked in by bastiK, 13 years ago |
applied #6856 - Enable plugins to add actions in popup menus (patch by Don-vip)
|
-
Property svn:eol-style
set to
native
|
File size:
826 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 | * @author Vincent
|
---|
12 | *
|
---|
13 | */
|
---|
14 | public class ListPopupMenu extends JPopupMenu {
|
---|
15 |
|
---|
16 | private JList[] lists;
|
---|
17 |
|
---|
18 | public ListPopupMenu(JList ... lists) {
|
---|
19 | this.lists = lists;
|
---|
20 | }
|
---|
21 |
|
---|
22 | /* (non-Javadoc)
|
---|
23 | * @see javax.swing.JPopupMenu#add(javax.swing.Action)
|
---|
24 | */
|
---|
25 | @Override
|
---|
26 | public JMenuItem add(Action a) {
|
---|
27 | if (lists != null && a instanceof ListSelectionListener) {
|
---|
28 | for (JList list : lists) {
|
---|
29 | list.addListSelectionListener((ListSelectionListener) a);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | return super.add(a);
|
---|
33 | }
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.