use of javax.swing.event.MenuListener in project triplea by triplea-game.
the class ViewMenu method addDrawTerritoryBordersAgain.
private void addDrawTerritoryBordersAgain() {
final JMenu drawBordersMenu = new JMenu();
drawBordersMenu.setMnemonic(KeyEvent.VK_O);
drawBordersMenu.setText("Draw Borders On Top");
final JRadioButton noneButton = new JRadioButton("Low");
noneButton.setMnemonic(KeyEvent.VK_L);
final JRadioButton mediumButton = new JRadioButton("Medium");
mediumButton.setMnemonic(KeyEvent.VK_M);
final JRadioButton highButton = new JRadioButton("High");
highButton.setMnemonic(KeyEvent.VK_H);
final ButtonGroup group = new ButtonGroup();
group.add(noneButton);
group.add(mediumButton);
group.add(highButton);
drawBordersMenu.addMenuListener(new MenuListener() {
@Override
public void menuSelected(final MenuEvent e) {
final IDrawable.OptionalExtraBorderLevel current = uiContext.getDrawTerritoryBordersAgain();
if (current == IDrawable.OptionalExtraBorderLevel.LOW) {
noneButton.setSelected(true);
} else if (current == IDrawable.OptionalExtraBorderLevel.MEDIUM) {
mediumButton.setSelected(true);
} else if (current == IDrawable.OptionalExtraBorderLevel.HIGH) {
highButton.setSelected(true);
}
}
@Override
public void menuDeselected(final MenuEvent e) {
}
@Override
public void menuCanceled(final MenuEvent e) {
}
});
noneButton.addActionListener(e -> {
if (noneButton.isSelected() && uiContext.getDrawTerritoryBordersAgain() != IDrawable.OptionalExtraBorderLevel.LOW) {
uiContext.setDrawTerritoryBordersAgain(IDrawable.OptionalExtraBorderLevel.LOW);
frame.getMapPanel().resetMap();
}
});
mediumButton.addActionListener(e -> {
if (mediumButton.isSelected() && uiContext.getDrawTerritoryBordersAgain() != IDrawable.OptionalExtraBorderLevel.MEDIUM) {
uiContext.setDrawTerritoryBordersAgain(IDrawable.OptionalExtraBorderLevel.MEDIUM);
frame.getMapPanel().resetMap();
}
});
highButton.addActionListener(e -> {
if (highButton.isSelected() && uiContext.getDrawTerritoryBordersAgain() != IDrawable.OptionalExtraBorderLevel.HIGH) {
uiContext.setDrawTerritoryBordersAgain(IDrawable.OptionalExtraBorderLevel.HIGH);
frame.getMapPanel().resetMap();
}
});
drawBordersMenu.add(noneButton);
drawBordersMenu.add(mediumButton);
drawBordersMenu.add(highButton);
add(drawBordersMenu);
}
use of javax.swing.event.MenuListener in project airavata by apache.
the class RunMenuItem method createWorkflowMenu.
/**
* Creates workflow menu.
*/
private void createWorkflowMenu() {
// this.launchDynamicWorkflowItem = createLaunchDynamicWorkflowItem();
createLaunchXBayaInterpreterItem();
// this.configMonitorItem = createConfigMonitoring();
// this.resumeMonitoringItem = createResumeMonitoring();
// this.pauseMonitoringItem = createPauseMonitoring();
// this.resetMonitoringItem = createResetMonitoring();
// stopWorkflowItem = createStopWorkflow();
runMenu = new JMenu("Run");
runMenu.setMnemonic(KeyEvent.VK_R);
runMenu.add(launchXBayaInterpreterItem);
// runMenu.add(launchDynamicWorkflowItem);
// runMenu.addSeparator();
// runMenu.add(stopWorkflowItem);
// runMenu.addSeparator();
// runMenu.add(this.resumeMonitoringItem);
// runMenu.add(this.pauseMonitoringItem);
// runMenu.add(this.resetMonitoringItem);
// runMenu.add(this.configMonitorItem);
runMenu.addMenuListener(new MenuListener() {
@Override
public void menuCanceled(MenuEvent e) {
}
@Override
public void menuDeselected(MenuEvent e) {
}
@Override
public void menuSelected(MenuEvent e) {
// stopWorkflowItem.setEnabled(isWorkflowRunning());
}
});
setupMonitors();
// startStopButtonStateUpdater();
executionModeChanged(engine.getConfiguration());
}
use of javax.swing.event.MenuListener in project org.alloytools.alloy by AlloyTools.
the class OurUtil method menu.
/**
* Construct a new JMenu and add it to an existing JMenuBar.
* <p>
* Note: every time the user expands then collapses this JMenu, we automatically
* enable all JMenu and JMenuItem objects in it.
*
* @param parent - the JMenuBar to add this Menu into (or null if we don't want
* to add it to a JMenuBar yet)
* @param label - the label to show on screen (if it contains '&' followed by
* 'a'..'z', we'll remove '&' and use it as mnemonic)
* @param func - if nonnull we'll call its "run()" method right before expanding
* this menu
*/
public static JMenu menu(JMenuBar parent, String label, final Runnable func) {
final JMenu x = new JMenu(label.replace("&", ""), false);
if (!Util.onMac()) {
int i = label.indexOf('&');
if (i >= 0 && i + 1 < label.length())
i = label.charAt(i + 1);
if (i >= 'a' && i <= 'z')
x.setMnemonic((i - 'a') + 'A');
else if (i >= 'A' && i <= 'Z')
x.setMnemonic(i);
}
x.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent e) {
if (func != null)
func.run();
}
@Override
public void menuDeselected(MenuEvent e) {
OurUtil.enableAll(x);
}
@Override
public void menuCanceled(MenuEvent e) {
OurUtil.enableAll(x);
}
});
if (parent != null)
parent.add(x);
return x;
}
use of javax.swing.event.MenuListener in project fql by CategoricalData.
the class ApplicationFrame method buildMenu.
/**
* Builds the menu
*/
private void buildMenu() {
final JMenuBar mainMenu;
final JMenu menuFile;
final JMenu menuEdit;
@SuppressWarnings("unused") JMenu menuAction;
final JMenu menuHelp;
mainMenu = new JMenuBar();
// Make the File Menu
menuFile = new JMenu("File");
addMenuItem(menuFile, new FileNewOverviewAction(this), KeyEvent.VK_N);
addMenuItem(menuFile, new FileOpenAction(this), KeyEvent.VK_O);
menuFile.addSeparator();
addMenuItem(menuFile, new FileSaveAction(this), KeyEvent.VK_S);
addMenuItem(menuFile, new FileSaveAsAction(this), KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK);
menuFile.addSeparator();
_recentFilesMenu = new JMenu("Open recent...");
menuFile.add(_recentFilesMenu);
updateRecentFilesMenu();
menuFile.addSeparator();
addMenuItem(menuFile, new OverviewDocumentInfoAction(this), KeyEvent.VK_I);
menuFile.addSeparator();
addMenuItem(menuFile, new FileQuitAction(this), KeyEvent.VK_Q);
mainMenu.add(menuFile);
menuFile.setMnemonic(KeyEvent.VK_F);
menuEdit = new JMenu("Edit");
menuEdit.add(new JMenuItem(new NewSketchAction(null, _overview)));
menuEdit.add(new JMenuItem(new ImportSketchAction(null, _overview)));
menuEdit.addSeparator();
menuEdit.add(_NewViewMenuItem = new JMenuItem(new NewViewAction(_overview)));
mainMenu.add(menuEdit);
menuEdit.addMenuListener(new MenuListener() {
@Override
public void menuSelected(final MenuEvent e1) {
final Object[] selection = _overview.getSelectionCells();
_NewViewMenuItem.setEnabled((selection.length == 1) && (selection[0] instanceof SketchNode));
}
@Override
public void menuDeselected(final MenuEvent e1) {
}
@Override
public void menuCanceled(final MenuEvent e1) {
}
});
menuEdit.addSeparator();
// If
addMenuItem(menuEdit, _ProgramSettingsItem = new JMenuItem("Preferences"), KeyEvent.VK_E);
// you
// change
// this
// title,
// update
// OSX.java
_ProgramSettingsItem.setToolTipText("Set Global Easik Properties");
_ProgramSettingsItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e1) {
final ProgramSettingsUI myUI = new ProgramSettingsUI(ApplicationFrame.this);
myUI.showDialog();
}
});
menuEdit.setMnemonic(KeyEvent.VK_E);
// Create help menu
menuHelp = new JMenu("Help");
mainMenu.add(menuHelp);
menuHelp.setMnemonic(KeyEvent.VK_H);
menuHelp.add(new HelpAction());
menuHelp.add(new AboutAction());
setJMenuBar(mainMenu);
}
use of javax.swing.event.MenuListener in project jdk8u_jdk by JetBrains.
the class bug4983388 method createAndShowGUI.
private static void createAndShowGUI() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menu.setMnemonic('F');
menuBar.add(menu);
JFrame frame = new JFrame();
frame.setJMenuBar(menuBar);
frame.pack();
frame.setVisible(true);
MenuListener listener = new TestMenuListener();
menu.addMenuListener(listener);
}
Aggregations