Java Code Examples for javax.swing.JMenuItem#setEnabled()

The following examples show how to use javax.swing.JMenuItem#setEnabled() . 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: DriverGUI.java    From openAGV with Apache License 2.0 6 votes vote down vote up
private void createDriverMenu() {
  driverMenu.removeAll();

  // Collect all available comm adapters/factories
  Set<VehicleCommAdapterDescription> availableDescriptions = new HashSet<>();
  vehicleEntryPool.getEntries().forEach((vehicleName, entry) -> {
    availableDescriptions.addAll(entry.getAttachmentInformation().getAvailableCommAdapters());
  });

  for (VehicleCommAdapterDescription description : availableDescriptions) {
    // If there's one vehicle not supported by this factory the selection can't be attached to it
    boolean factorySupportsSelectedVehicles = getSelectedVehicleEntries().stream()
        .map(entry -> entry.getAttachmentInformation().getAvailableCommAdapters())
        .allMatch(descriptions -> !Collections.disjoint(descriptions, availableDescriptions));

    List<String> vehiclesToAttach = new ArrayList<>();
    if (factorySupportsSelectedVehicles) {
      vehiclesToAttach = getSelectedVehicleNames();
    }

    Action action = new AttachCommAdapterAction(vehiclesToAttach, description);
    JMenuItem menuItem = driverMenu.add(action);
    menuItem.setEnabled(!vehiclesToAttach.isEmpty());
  }
}
 
Example 2
Source File: TabbedPane.java    From javamelody with Apache License 2.0 6 votes vote down vote up
@Override
protected JPopupMenu createPopupMenu() {
	final JPopupMenu menu = super.createPopupMenu();
	final CloseMenuSelectionHandler closeMenuSelectionHandler = new CloseMenuSelectionHandler();
	final JMenuItem closeMenuItem = new JMenuItem(I18N.getString("Fermer"));
	final JMenuItem closeOthersMenuItem = new JMenuItem(I18N.getString("Fermer_les_autres"));
	final JMenuItem closeAllMenuItem = new JMenuItem(I18N.getString("Fermer_tout"));
	closeMenuItem.setName(CLOSE);
	closeOthersMenuItem.setName(CLOSE_OTHERS);
	closeAllMenuItem.setName(CLOSE_ALL);
	closeMenuItem.addActionListener(closeMenuSelectionHandler);
	closeOthersMenuItem.addActionListener(closeMenuSelectionHandler);
	closeAllMenuItem.addActionListener(closeMenuSelectionHandler);
	menu.add(new JSeparator(), 0);
	menu.add(closeAllMenuItem, 0);
	menu.add(closeOthersMenuItem, 0);
	menu.add(closeMenuItem, 0);
	if (getTabComponentAt(getSelectedIndex()) == null) {
		closeMenuItem.setEnabled(false);
	}

	return menu;
}
 
Example 3
Source File: BindAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createBindingsSubmenu(JMenu menu) {
    if (menu.getMenuComponentCount() > 0)
        menu.removeAll();

    Node[] nodes = getActivatedNodes();
    if (nodes.length != 1)
        return;

    RADComponentCookie radCookie = nodes[0].getCookie(RADComponentCookie.class);
    if (radCookie == null)
        return;

    BindingProperty[][] bindingProps = radCookie.getRADComponent().getBindingProperties();
    BindingProperty[] props = bindingProps[(bindingProps[0].length==0) ? 1 : 0];
    if (props.length > 0) {
        for (BindingProperty prop : props) {
            BindingMenuItem mi = new BindingMenuItem(prop);
            mi.addActionListener(mi);
            menu.add(mi);
        }
    } else {
        JMenuItem item = new JMenuItem(NbBundle.getMessage(BindAction.class, "MSG_NoBinding")); // NOI18N
        item.setEnabled(false);
        menu.add(item);
    }
}
 
Example 4
Source File: MTabbedPane.java    From javamelody with Apache License 2.0 6 votes vote down vote up
protected JPopupMenu createPopupMenu() {
	final JPopupMenu menu = new JPopupMenu();
	final MenuSelectionHandler menuSelectionHandler = new MenuSelectionHandler();
	final int tabCount = getTabCount();
	final int selectedIndex = getSelectedIndex();
	for (int i = 0; i < tabCount; i++) {
		final JMenuItem menuItem = new JMenuItem(getTitleAt(i), getIconAt(i));
		if (i == selectedIndex) {
			menuItem.setFont(menuItem.getFont().deriveFont(Font.BOLD));
		}
		if (!isEnabledAt(i)) {
			menuItem.setEnabled(false);
		}
		menuItem.setName(String.valueOf(i));
		menuItem.addActionListener(menuSelectionHandler);
		menu.add(menuItem);
	}
	return menu;
}
 
Example 5
Source File: MetalworksFrame.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected JMenu buildViewsMenu() {
    JMenu views = new JMenu("Views");

    JMenuItem inBox = new JMenuItem("Open In-Box");
    JMenuItem outBox = new JMenuItem("Open Out-Box");
    outBox.setEnabled(false);

    inBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            openInBox();
        }
    });

    views.add(inBox);
    views.add(outBox);
    return views;
}
 
Example 6
Source File: OurUtil.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a new JMenuItem then add it to an existing JMenu.
 *
 * @param parent - the JMenu to add this JMenuItem into (or null if you don't
 *            want to add it to any JMenu yet)
 * @param label - the text to show on the menu
 * @param attrs - a list of attributes to apply onto the new JMenuItem
 *            <p>
 *            If one positive number a is supplied, we call setMnemonic(a)
 *            <p>
 *            If two positive numbers a and b are supplied, and a!=VK_ALT, and
 *            a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
 *            <p>
 *            If two positive numbers a and b are supplied, and a==VK_ALT or
 *            a==VK_SHIFT, we call setAccelerator(a | b)
 *            <p>
 *            If an ActionListener is supplied, we call addActionListener(x)
 *            <p>
 *            If an Boolean x is supplied, we call setEnabled(x)
 *            <p>
 *            If an Icon x is supplied, we call setIcon(x)
 */
public static JMenuItem menuItem(JMenu parent, String label, Object... attrs) {
    JMenuItem m = new JMenuItem(label, null);
    int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    boolean hasMnemonic = false;
    for (Object x : attrs) {
        if (x instanceof Character || x instanceof Integer) {
            int k = (x instanceof Character) ? ((int) ((Character) x)) : ((Integer) x).intValue();
            if (k < 0)
                continue;
            if (k == KeyEvent.VK_ALT) {
                hasMnemonic = true;
                accelMask = accelMask | InputEvent.ALT_MASK;
                continue;
            }
            if (k == KeyEvent.VK_SHIFT) {
                hasMnemonic = true;
                accelMask = accelMask | InputEvent.SHIFT_MASK;
                continue;
            }
            if (!hasMnemonic) {
                m.setMnemonic(k);
                hasMnemonic = true;
            } else
                m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
        }
        if (x instanceof ActionListener)
            m.addActionListener((ActionListener) x);
        if (x instanceof Icon)
            m.setIcon((Icon) x);
        if (x instanceof Boolean)
            m.setEnabled((Boolean) x);
    }
    if (parent != null)
        parent.add(m);
    return m;
}
 
Example 7
Source File: EditPopup.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
private boolean add(LogisimMenuItem item, String display) {
	if (shouldShow(item)) {
		JMenuItem menu = new JMenuItem(display);
		items.put(item, menu);
		menu.setEnabled(isEnabled(item));
		menu.addActionListener(listener);
		add(menu);
		return true;
	} else {
		return false;
	}
}
 
Example 8
Source File: AbstractPageListPopupListener.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Construct and show popup menu.
 * 
 * @param component Component.
 * @param link Selected page.
 * @param x Position.
 * @param y Position.
 */
private void showPopup(Component component, Page link, int x, int y) {

  // Menu name
  JPopupMenu popup = new JPopupMenu();
  JMenuItem menuItem = new JMenuItem(link.getTitle());
  menuItem.setEnabled(false);
  popup.add(menuItem);

  // Create sub menus
  createPopup(popup, link);

  popup.show(component, x, y);
  popup.addPopupMenuListener(this);
}
 
Example 9
Source File: MainMenu.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public void dataAdded(DataSet data) {
    // File -> Remove All
    JMenuItem item = this.getMenu(0).getItem(2);
    item.setEnabled(true);

    changeDefaultIntervalName();
}
 
Example 10
Source File: MainMenu.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public void dataCleared() {
    // File -> Remove All
    JMenuItem item = this.getMenu(0).getItem(2);
    item.setEnabled(false);

    changeDefaultIntervalName();
    enableChartSubMenu(false);
}
 
Example 11
Source File: ServicesMenu.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
public void addActions(ServiceDefinition definition) {
     List<Action> actions = getActionsFromDefinition(definition);
     if(actions.isEmpty()) {
        JMenuItem item = new JMenuItem("No custom commands supported");
        item.setEnabled(false);
        add(item);
     }
     else {
        for(Action action: actions) {
           add(new JMenuItem(action));
        }
     }
}
 
Example 12
Source File: MainFrame.java    From FCMFrame with Apache License 2.0 5 votes vote down vote up
public JMenuItem createMenuItem(JMenu menu, String label, String mnemonic, String accessibleDescription, Action action) {
	JMenuItem mi = (JMenuItem) menu.add(new JMenuItem(label));
	mi.addActionListener(action);
	if(action == null) {
		mi.setEnabled(false);
	}
	return mi;
}
 
Example 13
Source File: CRegisterMenuProvider.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public JPopupMenu getRegisterMenu(final int registerNumber) {
  final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();

  if (debugger == null) {
    return null;
  }

  final JPopupMenu menu = new JPopupMenu();

  final BigInteger value = m_dataProvider.getRegisterInformation(registerNumber).getValue();

  menu.add(CActionProxy.proxy(new CCopyRegisterValueAction(value.toString(16).toUpperCase())));

  final MemorySection section = ProcessHelpers.getSectionWith(
      debugger.getProcessManager().getMemoryMap(), new CAddress(value));

  final JMenuItem gotoAddress = menu.add(CActionProxy.proxy(
      new CGotoOffsetAction(m_debugPerspectiveModel, new CAddress(value))));
  gotoAddress.setEnabled(section != null);

  if (containsAddress(
      m_debugPerspectiveModel.getGraphModel().getGraph().getRawView(), value.longValue())) {
    menu.add(CActionProxy.proxy(new CZoomToAddressAction(
        m_debugPerspectiveModel.getGraphModel().getGraph(), new CAddress(value),
        debugger.getModule(new RelocatedAddress(new CAddress(value))))));
  } else {
    final IViewContainer container = m_debugPerspectiveModel.getGraphModel().getViewContainer();

    menu.add(CActionProxy.proxy(new CSearchAction(
        m_debugPerspectiveModel.getGraphModel().getParent(), container, new CAddress(value))));
  }

  return menu;
}
 
Example 14
Source File: GuiMouseListener.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private JMenuItem createBestowCurseMenu(WorldObject target) {
	JMenuItem bestowCurseMenuItem = MenuFactory.createJMenuItem(new ChooseCurseAction(playerCharacter, imageInfoReader, soundIdReader, world, (WorldPanel)container, dungeonMaster, parentFrame, target), soundIdReader);
	bestowCurseMenuItem.setText(Actions.BESTOW_CURSE_ACTION.getSimpleDescription());
	bestowCurseMenuItem.setEnabled(Game.canActionExecute(playerCharacter, Actions.BESTOW_CURSE_ACTION, Args.EMPTY, world, target));
   	addToolTips(Actions.BESTOW_CURSE_ACTION, bestowCurseMenuItem);
   	setMenuIcon(bestowCurseMenuItem, Actions.BESTOW_CURSE_ACTION.getImageIds(playerCharacter));
	return bestowCurseMenuItem;
}
 
Example 15
Source File: CProximityNodeMenu.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new proximity node menu.
 *
 * @param parent Parent window used for dialogs.
 * @param graph Graph the proximity belong to.
 * @param node Clicked proximity node.
 */
public CProximityNodeMenu(
    final JFrame parent, final ZyGraph graph, final ZyProximityNode<INaviViewNode> node) {
  Preconditions.checkNotNull(parent, "IE02150: Parent argument can not be null");

  Preconditions.checkNotNull(graph, "IE00972: Graph argument can't be null");

  Preconditions.checkNotNull(node, "IE00973: Node argument can't be null");

  add(CActionProxy.proxy(new CUnhideNodesAction(parent, graph, node)));

  addSeparator();

  final JMenuItem unhideParentItem = new JMenuItem(CActionProxy.proxy(
      new CUnhideParentsAction(parent, graph, node)));
  unhideParentItem.setEnabled(!node.isIncoming());
  add(unhideParentItem);

  final JMenuItem unhideChildrenItem = new JMenuItem(CActionProxy.proxy(
      new CUnhideChildrenAction(parent, graph, node)));
  unhideChildrenItem.setEnabled(node.isIncoming());
  add(unhideChildrenItem);

  addSeparator();

  add(CActionProxy.proxy(new CUnhideAndSelectAction(graph, node)));
  add(CActionProxy.proxy(new CUnhideAndAddToSelectionAction(graph, node)));
}
 
Example 16
Source File: UIUtil.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Insert a pseudo-item, to be used as a menu title.
 *
 * @param menu the containing menu
 * @param text the title text
 */
public static void insertTitle (JMenu menu,
                                String text)
{
    JMenuItem title = new JMenuItem(text);
    title.setHorizontalAlignment(SwingConstants.CENTER);
    title.setEnabled(false);
    menu.add(title);
    menu.addSeparator();
}
 
Example 17
Source File: QFixMessengerFrame.java    From quickfix-messenger with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void initFileMenu()
{
	fileMenu = new JMenu("File");
	fileMenu.setMnemonic('F');

	JMenuItem newProjectMenuItem = new JMenuItem("New Project");
	newProjectMenuItem.setIcon(IconBuilder.build(
			getMessenger().getConfig(), IconBuilder.NEW_ICON));
	newProjectMenuItem.setMnemonic('N');
	newProjectMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
			InputEvent.CTRL_DOWN_MASK));
	newProjectMenuItem
			.addActionListener(new NewProjectActionListener(this));

	saveProjectMenuItem = new JMenuItem("Save Project");
	saveProjectMenuItem.setIcon(IconBuilder.build(getMessenger()
			.getConfig(), IconBuilder.SAVE_ICON));
	saveProjectMenuItem.setMnemonic('S');
	saveProjectMenuItem.setAccelerator(KeyStroke.getKeyStroke(
			KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
	saveProjectMenuItem.addActionListener(new SaveProjectActionListener(
			this));
	saveProjectMenuItem.setEnabled(false);

	JMenuItem openProjectMenuItem = new JMenuItem("Open Project");
	openProjectMenuItem.setIcon(IconBuilder.build(getMessenger()
			.getConfig(), IconBuilder.OPEN_ICON));
	openProjectMenuItem.setMnemonic('O');
	openProjectMenuItem.setAccelerator(KeyStroke.getKeyStroke(
			KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
	openProjectMenuItem.addActionListener(new OpenProjectActionListener(
			this));

	closeProjectMenuItem = new JMenuItem("Close Project");
	closeProjectMenuItem.setIcon(IconBuilder.build(getMessenger()
			.getConfig(), IconBuilder.CLOSE_ICON));
	closeProjectMenuItem.setMnemonic('C');
	closeProjectMenuItem.addActionListener(new CloseProjectActionListener(
			this));
	closeProjectMenuItem.setEnabled(false);

	JMenuItem importMessageMenuItem = new JMenuItem("Import Message");
	importMessageMenuItem.setIcon(IconBuilder.build(getMessenger()
			.getConfig(), IconBuilder.IMPORT_ICON));
	importMessageMenuItem.setMnemonic('I');
	importMessageMenuItem.setAccelerator(KeyStroke.getKeyStroke(
			KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK));
	importMessageMenuItem
			.addActionListener(new ImportMessageActionListener(this));

	JMenuItem exportMessageMenuItem = new JMenuItem("Export Message");
	exportMessageMenuItem.setIcon(IconBuilder.build(getMessenger()
			.getConfig(), IconBuilder.EXPORT_ICON));
	exportMessageMenuItem
			.addActionListener(new ExportMessageActionListener(this));
	exportMessageMenuItem.setMnemonic('X');
	exportMessageMenuItem.setAccelerator(KeyStroke.getKeyStroke(
			KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK));

	JMenuItem exitMenuItem = new JMenuItem("Exit");
	exitMenuItem.setIcon(IconBuilder.build(getMessenger().getConfig(),
			IconBuilder.EXIT_ICON));
	exitMenuItem.setMnemonic('x');
	exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
			InputEvent.ALT_DOWN_MASK));
	exitMenuItem.addActionListener(new FrameExitActionListener(this));

	fileMenu.add(newProjectMenuItem);
	fileMenu.add(saveProjectMenuItem);
	fileMenu.add(openProjectMenuItem);
	fileMenu.add(closeProjectMenuItem);
	fileMenu.addSeparator();
	fileMenu.add(importMessageMenuItem);
	fileMenu.add(exportMessageMenuItem);
	fileMenu.addSeparator();
	fileMenu.add(exitMenuItem);
}
 
Example 18
Source File: QuickActionMenu.java    From freecol with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Add menu items for role manipulation for a unit.
 *
 * Note "clear speciality" is here too to keep it well separated from
 * other items.
 *
 * @param unitLabel The {@code UnitLabel} specifying the unit.
 * @return True if menu items were added and a separator is now needed.
 */
private boolean addRoleItems(final UnitLabel unitLabel) {
    final Unit unit = unitLabel.getUnit();
    final Role role = unit.getRole();
    final int roleCount = unit.getRoleCount();
    boolean separatorNeeded = false;

    UnitLocation uloc = (unit.isInEurope()) ? unit.getOwner().getEurope()
        : unit.getSettlement();
    if (uloc == null) return false;
    for (Role r : transform(unit.getAvailableRoles(null),
                            r2 -> r2 != role)) {
        JMenuItem newItem;
        if (r.isDefaultRole()) { // Always valid
            newItem = createRoleItem(unitLabel, role, roleCount, r, 0, 0);
        } else {
            newItem = null;
            for (int count = r.getMaximumCount(); count > 0; count--) {
                List<AbstractGoods> req = unit.getGoodsDifference(r, count);
                try {
                    int price = uloc.priceGoods(req);
                    if (unit.getOwner().checkGold(price)) {
                        newItem = createRoleItem(unitLabel, role, roleCount,
                                                 r, count, price);
                        break;
                    }
                } catch (FreeColException fce) {
                    continue;
                }
            }
        }
        if (newItem != null) {
            this.add(newItem);
            separatorNeeded = true;
        }
    }

    UnitTypeChange uc = unit.getUnitChange(UnitChangeType.CLEAR_SKILL);
    if (uc != null) {
        if (separatorNeeded) this.addSeparator();
        JMenuItem menuItem = Utility.localizedMenuItem("quickActionMenu.clearSpeciality",
            new ImageIcon(gui.getImageLibrary().getTinyUnitTypeImage(uc.to)));
        menuItem.setActionCommand(UnitAction.CLEAR_SPECIALITY.toString());
        menuItem.addActionListener(unitLabel);
        this.add(menuItem);
        if (unit.getLocation() instanceof Building
            && !((Building)unit.getLocation()).canAddType(uc.to)) {
            menuItem.setEnabled(false);
        }
        separatorNeeded = true;
    }
    return separatorNeeded;
}
 
Example 19
Source File: ImageViewer.java    From scifio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/** Constructs an image viewer. */
	public ImageViewer(final Context context) {
		super(TITLE);
		context.inject(this);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		addWindowListener(this);

		// content pane
		pane = new JPanel();
		pane.setLayout(new BorderLayout());
		setContentPane(pane);
		setSize(350, 350); // default size

		// navigation sliders
		sliderPanel = new JPanel();
		sliderPanel.setVisible(false);
		sliderPanel.setBorder(new EmptyBorder(5, 3, 5, 3));
		sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.Y_AXIS));
		pane.add(BorderLayout.SOUTH, sliderPanel);

		final JPanel nPanel = new JPanel();
		nPanel.setLayout(new BoxLayout(nPanel, BoxLayout.X_AXIS));
		sliderPanel.add(nPanel);
		sliderPanel.add(Box.createVerticalStrut(2));

		nSlider = new JSlider(1, 1);
		nSlider.setEnabled(false);
		nSlider.addChangeListener(this);
		nPanel.add(new JLabel("N"));
		nPanel.add(Box.createHorizontalStrut(3));
		nPanel.add(nSlider);

		final JPanel ztcPanel = new JPanel();
		ztcPanel.setLayout(new BoxLayout(ztcPanel, BoxLayout.X_AXIS));
		sliderPanel.add(ztcPanel);

		// image icon
		final BufferedImage dummy = AWTImageTools.makeImage(new byte[1][1], 1, 1,
			false);
		icon = new ImageIcon(dummy);
		iconLabel = new JLabel(icon, SwingConstants.LEFT);
		iconLabel.setVerticalAlignment(SwingConstants.TOP);
		pane.add(new JScrollPane(iconLabel));

		// cursor probe
		probeLabel = new JLabel(" ");
		probeLabel.setHorizontalAlignment(SwingConstants.CENTER);
		probeLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
		pane.add(BorderLayout.NORTH, probeLabel);
		iconLabel.addMouseMotionListener(this);

		// menu bar
		final JMenuBar menubar = new JMenuBar();
		// FIXME: currently the menu bar is disabled to restrict the use of
		// ImageViewer to the Show command. We could attempt to get this
		// implementation working nicely, or just convert to an IJ2
		// implementation.
//		setJMenuBar(menubar);

		final JMenu file = new JMenu("File");
		file.setMnemonic('f');
		menubar.add(file);
		final JMenuItem fileOpen = new JMenuItem("Open...");
		fileOpen.setMnemonic('o');
		fileOpen.setActionCommand("open");
		fileOpen.addActionListener(this);
		file.add(fileOpen);
		fileSave = new JMenuItem("Save...");
		fileSave.setMnemonic('s');
		fileSave.setEnabled(false);
		fileSave.setActionCommand("save");
		fileSave.addActionListener(this);
		file.add(fileSave);
		fileView = new JMenuItem("View Metadata...");
		final JMenuItem fileExit = new JMenuItem("Exit");
		fileExit.setMnemonic('x');
		fileExit.setActionCommand("exit");
		fileExit.addActionListener(this);
		file.add(fileExit);

		final JMenu options = new JMenu("Options");
		options.setMnemonic('p');
		menubar.add(options);
		final JMenuItem optionsFPS = new JMenuItem("Frames per Second...");
		optionsFPS.setMnemonic('f');
		optionsFPS.setActionCommand("fps");
		optionsFPS.addActionListener(this);
		options.add(optionsFPS);

		final JMenu help = new JMenu("Help");
		help.setMnemonic('h');
		menubar.add(help);
		final JMenuItem helpAbout = new JMenuItem("About...");
		helpAbout.setMnemonic('a');
		helpAbout.setActionCommand("about");
		helpAbout.addActionListener(this);
		help.add(helpAbout);

		// add key listener to focusable components
		nSlider.addKeyListener(this);
	}
 
Example 20
Source File: ProgrammableGenerator.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
private JMenuItem createItem(boolean enabled, String label) {
	JMenuItem ret = new JMenuItem(label);
	ret.setEnabled(enabled);
	ret.addActionListener(this);
	return ret;
}