source: josm/trunk/src/org/openstreetmap/josm/gui/ModeMenu.java@ 16695

Last change on this file since 16695 was 15445, checked in by Don-vip, 5 years ago

fix #18210 - fix mode menu (add items properly to display shortcuts) and fix definition of lasso mode to consider it a traditional mapmode

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import static org.openstreetmap.josm.tools.I18n.trc;
5
6import java.beans.PropertyChangeListener;
7
8import javax.swing.Action;
9import javax.swing.JButton;
10import javax.swing.JCheckBoxMenuItem;
11import javax.swing.JMenu;
12import javax.swing.JMenuItem;
13
14/**
15 * Mode menu. Unlike traditional menus, default menu item is based on {@link JCheckBoxMenuItem}.
16 * @since 15445
17 */
18public class ModeMenu extends JMenu {
19
20 /**
21 * Constructs a new {@code ModeMenu}.
22 */
23 public ModeMenu() {
24 /* I18N: mnemonic: M */
25 super(trc("menu", "Mode"));
26 }
27
28 @Override
29 protected JMenuItem createActionComponent(Action a) {
30 JCheckBoxMenuItem mi = new JCheckBoxMenuItem() {
31 @Override
32 protected PropertyChangeListener createActionPropertyChangeListener(Action a) {
33 PropertyChangeListener pcl = createActionChangeListener(this);
34 if (pcl == null) {
35 pcl = super.createActionPropertyChangeListener(a);
36 }
37 return pcl;
38 }
39 };
40 mi.setHorizontalTextPosition(JButton.TRAILING);
41 mi.setVerticalTextPosition(JButton.CENTER);
42 return mi;
43 }
44}
Note: See TracBrowser for help on using the repository browser.