Changeset 5884 in josm
- Timestamp:
- 2013-04-19T01:31:16+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/widgets/PopupMenuLauncher.java
r3083 r5884 7 7 import javax.swing.JPopupMenu; 8 8 9 /** 10 * Utility class that helps to display popup menus on mouse events. 11 * @since 2688 12 */ 9 13 public class PopupMenuLauncher extends MouseAdapter { 10 private JPopupMenu menu; 14 private final JPopupMenu menu; 11 15 16 /** 17 * Creates a new {@link PopupMenuLauncher} with no defined menu. 18 * It is then needed to override the {@link #launch} method. 19 * @see #launch(MouseEvent) 20 */ 12 21 public PopupMenuLauncher() { 13 menu = null;22 this(null); 14 23 } 24 25 /** 26 * Creates a new {@link PopupMenuLauncher} with the given menu. 27 * @param menu The popup menu to display 28 */ 15 29 public PopupMenuLauncher(JPopupMenu menu) { 16 30 this.menu = menu; … … 38 52 } 39 53 54 /** 55 * Launches the popup menu according to the given mouse event. 56 * This method needs to be overriden if the default constructor has been called. 57 * @param evt A mouse event 58 */ 40 59 public void launch(MouseEvent evt) { 41 60 if (menu != null) { 42 menu.show(evt.getComponent(), evt.getX(),evt.getY()); 61 menu.show(evt.getComponent(), evt.getX(), evt.getY()); 43 62 } 44 63 } 64 65 /** 66 * @return the popup menu if defined, {@code null} otherwise. 67 * @since 5884 68 */ 69 public final JPopupMenu getMenu() { 70 return menu; 71 } 45 72 }
Note:
See TracChangeset
for help on using the changeset viewer.