Java Code Examples for javax.swing.JCheckBoxMenuItem#setMnemonic()

The following examples show how to use javax.swing.JCheckBoxMenuItem#setMnemonic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private void addShowMapDetails() {
  showMapDetails = new JCheckBoxMenuItem("Show Map Details");
  showMapDetails.setMnemonic(KeyEvent.VK_D);
  showMapDetails.setSelected(TileImageFactory.getShowReliefImages());
  showMapDetails.addActionListener(
      e -> {
        if (TileImageFactory.getShowReliefImages() == showMapDetails.isSelected()) {
          return;
        }
        TileImageFactory.setShowReliefImages(showMapDetails.isSelected());
        new Thread(
                () -> frame.getMapPanel().updateCountries(gameData.getMap().getTerritories()),
                "Show map details thread")
            .start();
      });
  add(showMapDetails);
}
 
Example 2
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void addShowMapBlends() {
  showMapBlends = new JCheckBoxMenuItem("Show Map Blends");
  showMapBlends.setMnemonic(KeyEvent.VK_B);
  if (uiContext.getMapData().getHasRelief()
      && showMapDetails.isEnabled()
      && showMapDetails.isSelected()) {
    showMapBlends.setEnabled(true);
    showMapBlends.setSelected(TileImageFactory.getShowMapBlends());
  } else {
    showMapBlends.setSelected(false);
    showMapBlends.setEnabled(false);
  }
  showMapBlends.addActionListener(
      e -> {
        if (TileImageFactory.getShowMapBlends() == showMapBlends.isSelected()) {
          return;
        }
        TileImageFactory.setShowMapBlends(showMapBlends.isSelected());
        TileImageFactory.setShowMapBlendMode(uiContext.getMapData().getMapBlendMode());
        TileImageFactory.setShowMapBlendAlpha(uiContext.getMapData().getMapBlendAlpha());
        new Thread(
                () -> frame.getMapPanel().updateCountries(gameData.getMap().getTerritories()),
                "Show map Blends thread")
            .start();
      });
  add(showMapBlends);
}
 
Example 3
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void addShowUnitsMenu() {
  final JCheckBoxMenuItem showUnitsBox = new JCheckBoxMenuItem("Show Units");
  showUnitsBox.setMnemonic(KeyEvent.VK_U);
  showUnitsBox.setSelected(true);
  showUnitsBox.addActionListener(
      e -> {
        final boolean tfselected = showUnitsBox.isSelected();
        uiContext.setShowUnits(tfselected);
        frame.getMapPanel().resetMap();
      });
  add(showUnitsBox);
}
 
Example 4
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void addShowTerritoryEffects() {
  final JCheckBoxMenuItem territoryEffectsBox = new JCheckBoxMenuItem("Show TerritoryEffects");
  territoryEffectsBox.setMnemonic(KeyEvent.VK_T);
  territoryEffectsBox.addActionListener(
      e -> {
        final boolean tfselected = territoryEffectsBox.isSelected();
        uiContext.setShowTerritoryEffects(tfselected);
        frame.getMapPanel().resetMap();
      });
  add(territoryEffectsBox);
  territoryEffectsBox.setSelected(true);
}
 
Example 5
Source File: SwingSet2.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Create a checkbox menu menu item.
 *
 * @param menu the menu
 * @param label the label
 * @param mnemonic the mnemonic
 * @param accessibleDescription the accessible description
 * @param action the action
 * @return the j menu item
 */
private JMenuItem createCheckBoxMenuItem(JMenu menu, String label,
		String mnemonic,
		String accessibleDescription,
		Action action) {
	JCheckBoxMenuItem mi = (JCheckBoxMenuItem)menu.add(
			new JCheckBoxMenuItem(getString(label)));
	mi.setMnemonic(getMnemonic(mnemonic));
	mi.getAccessibleContext().setAccessibleDescription(getString(
			accessibleDescription));
	mi.addActionListener(action);
	return mi;
}