Last change
on this file since 11921 was 11747, checked in by Don-vip, 7 years ago |
checkstyle - NoWhiteSpaceBefore ...
|
-
Property svn:eol-style
set to
native
|
File size:
748 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 final JList<?>[] lists;
|
---|
17 |
|
---|
18 | public ListPopupMenu(JList<?>... lists) {
|
---|
19 | this.lists = lists;
|
---|
20 | }
|
---|
21 |
|
---|
22 | @Override
|
---|
23 | public JMenuItem add(Action a) {
|
---|
24 | if (lists != null && a instanceof ListSelectionListener) {
|
---|
25 | for (JList<?> list : lists) {
|
---|
26 | list.addListSelectionListener((ListSelectionListener) a);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | return super.add(a);
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.