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

The following examples show how to use javax.swing.JMenuItem#setText() . 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: CopyPastePopupMenu.java    From IrScrutinizer with GNU General Public License v3.0 6 votes vote down vote up
public CopyPastePopupMenu(boolean paste) {
    super();
    copyMenuItem = new JMenuItem();

    copyMenuItem.setIcon(new javax.swing.ImageIcon(CopyPastePopupMenu.class.getResource("/icons/Crystal-Clear/22x22/actions/editcopy.png"))); // NOI18N
    copyMenuItem.setMnemonic('C');
    copyMenuItem.setText("Copy");
    copyMenuItem.setToolTipText("Copy content of window to clipboard (ignoring any selection).");
    copyMenuItem.addActionListener(new ActionListenerImpl());
    super.add(copyMenuItem);

    if (paste) {
        pasteMenuItem = new JMenuItem();
        pasteMenuItem.setIcon(new javax.swing.ImageIcon(CopyPastePopupMenu.class.getResource("/icons/Crystal-Clear/22x22/actions/editpaste.png"))); // NOI18N
        pasteMenuItem.setText("Paste");
        pasteMenuItem.setToolTipText("Paste from clipboard, replacing previous content.");
        pasteMenuItem.addActionListener(new ActionListenerImpl1());
        super.add(pasteMenuItem);
    }
}
 
Example 2
Source File: RecentItems.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
/**
 * Add list orecentProjFile recent projects as Menu Items to the Recent
 * projects menu
 *
 *
 * @param recentProj instance orecentProjFile the menu to address
 * <code>Recent Projects</code>
 */
public void updateMenu(JMenu recentProj) {
    recentProj.removeAll();
    try {
        for (String file : recentProjects) {
            recentItemMenu = new JMenuItem();
            recentItemMenu.setFont(new java.awt.Font("sansserif", 0, 11));
            recentItemMenu.setText(toName(file));
            recentItemMenu.setToolTipText(file);
            recentProj.add(recentItemMenu);
            addlistener(recentItemMenu);
        }
    } catch (Exception ex) {
        Logger.getLogger(RecentItems.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 3
Source File: MicroarrayMenuBar.java    From chipster with MIT License 6 votes vote down vote up
private JMenuItem getLoadLocalSessionMenuItem(final boolean clear) {
	JMenuItem loadLocalSessionMenuItem = new JMenuItem();
	loadLocalSessionMenuItem.setText("Open local session...");
	if (clear) {
		loadLocalSessionMenuItem.setText("Open local session...");
		loadLocalSessionMenuItem.setAccelerator(KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
	} else {
		loadLocalSessionMenuItem.setText("Local session...");
	}
	loadLocalSessionMenuItem.addActionListener(new java.awt.event.ActionListener() {
		public void actionPerformed(java.awt.event.ActionEvent e) {
			try {
				application.loadSession(false, false, clear);
			} catch (Exception ioe) {
				application.reportException(ioe);
			}
		}
	});
	return loadLocalSessionMenuItem;
}
 
Example 4
Source File: BasePluginManager.java    From yeti with MIT License 6 votes vote down vote up
public ArrayList<JMenuItem> getPlugins() {
    ArrayList<JMenuItem> result = new ArrayList<>();

    for (String filename : UtilFunctions.filesFromDir(scriptLocation)) {
        JMenuItem miPlugin = new JMenuItem();
        miPlugin.setText(filename);
        miPlugin.setName(filename);
        miPlugin.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pluginMenuEvent(evt);
            }
        });
        result.add(miPlugin);
    }
    return result;
}
 
Example 5
Source File: GuiMouseListener.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void addObfuscateAction(JPopupMenu menu, WorldObject worldObject, ManagedOperation action) {
	if (action == Actions.OBFUSCATE_DEATH_REASON_ACTION) {
		final JMenuItem menuItem;
		if (canPlayerCharacterPerformAction(worldObject, action)) {
			ChooseDeathReasonAction guiAction = new ChooseDeathReasonAction(playerCharacter, imageInfoReader, soundIdReader, world, container, dungeonMaster, worldObject, parentFrame);
			menuItem = MenuFactory.createJMenuItem(guiAction, soundIdReader);
			menuItem.setText(action.getSimpleDescription());
			menu.add(menuItem);
		} else if (canPlayerCharacterPerformActionUnderCorrectCircumstances(worldObject, action)) {
			menuItem = createDisabledMenuItem(action);
			menu.add(menuItem);
		} else {
			menuItem = null;
		}
		addToolTips(action, menuItem);
		addImageIcon(action, menuItem);
	}
}
 
Example 6
Source File: DefaultsDisplay.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public ValueRenderer(Color colors[]) {
    super(colors);
    buttonIconRenderer = new JButton();
    buttonIconRenderer.setBorderPainted(false);
    buttonIconRenderer.setContentAreaFilled(false);
    buttonIconRenderer.setText("(for AbstractButtons only)");
    radioIconRenderer = new JRadioButton();
    radioIconRenderer.setBorderPainted(false);
    radioIconRenderer.setText("for JRadioButtons only)");
    checkboxIconRenderer = new JCheckBox();
    checkboxIconRenderer.setBorderPainted(false);
    checkboxIconRenderer.setText("for JCheckBoxes only)");
    menuItemIconRenderer = new JMenuItem();
    menuItemIconRenderer.setBorderPainted(false);
    menuItemIconRenderer.setText("(for JMenuItems only)");
    
}
 
Example 7
Source File: UtilitiesActionsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JComponent[] getMenuPresenters() {
    itm1 = new JMenuItem();
    itm1.setText("3");
    itm2 = new JMenuItem();
    itm2.setText("4");
    return new JComponent[] {
        itm1,
        itm2,
        this
    };
}
 
Example 8
Source File: MsgTextAreaJPopupMenu.java    From talent-aio with GNU Lesser General Public License v2.1 5 votes vote down vote up
private JMenuItem getCopyMenuItem()
{
	JMenuItem copyMenuItem = new JMenuItem();
	copyMenuItem.setText("copy");
	copyMenuItem.addActionListener(this);
	return copyMenuItem;
}
 
Example 9
Source File: SequenceModule.java    From chipster with MIT License 5 votes vote down vote up
private JMenuItem getCreateFromTextMenuItem() {
	JMenuItem createFromTextMenuItem = new JMenuItem();
	createFromTextMenuItem.setText("Text...");
	createFromTextMenuItem.addActionListener(new java.awt.event.ActionListener() {
		public void actionPerformed(java.awt.event.ActionEvent e) {
			doCreateFromText();
		}
	});
	return createFromTextMenuItem;
}
 
Example 10
Source File: GuiMouseListener.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void addCookAction(JPopupMenu menu, WorldObject worldObject) {
	if (Actions.COOK_ACTION.isValidTarget(playerCharacter, worldObject, world)) {
		DefaultActionContainingArgsAction defaultActionContainingArgsAction = new DefaultActionContainingArgsAction(playerCharacter, imageInfoReader, container, Actions.COOK_ACTION, world, dungeonMaster, worldObject, soundIdReader);
		List<WorldObject> worldObjects = playerCharacter.getProperty(Constants.INVENTORY).getWorldObjectsByFunction(Constants.FOOD, w -> true);
		JMenuItem cookMenuItem = MenuFactory.createJMenuItem(new ChooseWorldObjectAction(worldObjects, playerCharacter, imageInfoReader, soundIdReader, world, container, dungeonMaster, defaultActionContainingArgsAction, parentFrame, WorldObjectMapper.INVENTORY_ID), soundIdReader);
		cookMenuItem.setText("Cook...");
		cookMenuItem.setEnabled(worldObjects.size() > 0);
		setMenuIcon(cookMenuItem, ImageIds.COOKING);
		addToolTips(Actions.COOK_ACTION, cookMenuItem);
		menu.add(cookMenuItem);
	}
}
 
Example 11
Source File: MsgTextAreaJPopupMenu.java    From talent-aio with GNU Lesser General Public License v2.1 5 votes vote down vote up
private JMenuItem getSelectallMenuItem()
{
	JMenuItem pasteMenuItem = new JMenuItem();
	pasteMenuItem.setText("select all");
	pasteMenuItem.addActionListener(this);
	return pasteMenuItem;
}
 
Example 12
Source File: GuiMouseListener.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void addAccessContainerAction(JPopupMenu menu, WorldObject worldObject) {
	if (Actions.GET_ITEM_FROM_INVENTORY_ACTION.canExecute(playerCharacter, worldObject, Args.EMPTY, world) && !worldObject.hasProperty(Constants.ILLUSION_CREATOR_ID)) {
		JMenuItem guiBarterItem = MenuFactory.createJMenuItem(new GuiBarterAction(playerCharacter, world, dungeonMaster, container, worldObject, imageInfoReader, soundIdReader, parentFrame), soundIdReader);
		guiBarterItem.setText("Access container...");
		setMenuIcon(guiBarterItem, Actions.SELL_ACTION.getImageIds(playerCharacter));
		guiBarterItem.setToolTipText("store or retrieve items from a container");
		menu.add(guiBarterItem);
	}
}
 
Example 13
Source File: GuiMouseListener.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void addCreateOrganizationMenu(JMenu menu) {
	JMenuItem createOrganizationMenuItem = MenuFactory.createJMenuItem(new GuiCreateOrganizationAction(playerCharacter, imageInfoReader, soundIdReader, world, (WorldPanel)container, dungeonMaster, parentFrame), soundIdReader);
	createOrganizationMenuItem.setText("Create Organization...");
	setMenuIcon(createOrganizationMenuItem, Actions.CREATE_PROFESSION_ORGANIZATION_ACTION.getImageIds(playerCharacter));
	createOrganizationMenuItem.setToolTipText("create an organization based on a deity or profession");
	menu.add(createOrganizationMenuItem);
}
 
Example 14
Source File: UtilitiesActionsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JComponent[] getMenuPresenters() {
    itm1 = new JMenuItem();
    itm1.setText("1");
    itm2 = new Dyna2();
    itm2.setText("2");
    return new JComponent[] {
        itm1,
        itm2
    };
}
 
Example 15
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Populate edit menu.
 */
private void populateEditMenu() {
  this.undoItem = new JMenuItem("Undo");
  this.undoItem.addActionListener(this.undoMgr);
  this.undoItem.setEnabled(false);
  this.undoItem.setMnemonic(KeyEvent.VK_U);
  this.undoItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK));
  this.editMenu.add(this.undoItem);
  this.editMenu.addSeparator();
  HashMap<Object, Action> actionMap = createEditActionMap();
  // Cut
  this.cutAction = actionMap.get(DefaultEditorKit.cutAction);
  this.cutAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_T);
  this.cutAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X,
      InputEvent.CTRL_MASK));
  this.cutAction.setEnabled(false);
  JMenuItem cutItem = new JMenuItem(this.cutAction);
  cutItem.setText("Cut");
  this.editMenu.add(cutItem);
  // Copy
  this.copyAction = actionMap.get(DefaultEditorKit.copyAction);
  this.copyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
  this.copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C,
      InputEvent.CTRL_MASK));
  this.copyAction.setEnabled(false);
  JMenuItem copyItem = new JMenuItem(this.copyAction);
  copyItem.setText("Copy");
  this.editMenu.add(copyItem);
  // Paste
  Action pasteAction = actionMap.get(DefaultEditorKit.pasteAction);
  pasteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_P);
  pasteAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V,
      InputEvent.CTRL_MASK));
  JMenuItem pasteItem = new JMenuItem(pasteAction);
  pasteItem.setText("Paste");
  this.editMenu.add(pasteItem);
}
 
Example 16
Source File: SelectInAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Add item for an action into a submenu (it the action exists).
 *
 * @param parent Parent to add the new item into.
 * @param action ID of the action for {@link #getAction(String)}
 * @param displayName Display name for the action.
 */
private void addActionItem(JMenu parent,
        String action, String displayName) {

    Action a = getAction(action);
    if (a != null) {
        JMenuItem item = new JMenuItem(a);
        item.setText(displayName);
        item.setIcon(null);
        parent.add(item);
    }
}
 
Example 17
Source File: TextComponentPopupMenu.java    From energy2d with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TextComponentPopupMenu(JTextComponent t) {

		text = t;

		actions = new HashMap<Object, Action>();
		for (Action act : text.getActions())
			actions.put(act.getValue(Action.NAME), act);

		boolean isMac = System.getProperty("os.name").startsWith("Mac");

		miCopy = new JMenuItem(actions.get(DefaultEditorKit.copyAction));
		miCopy.setText("Copy");
		miCopy.setAccelerator(isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_MASK) : KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK));
		add(miCopy);

		miCut = new JMenuItem(actions.get(DefaultEditorKit.cutAction));
		miCut.setText("Cut");
		miCut.setAccelerator(isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_MASK) : KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK));
		add(miCut);

		miPaste = new JMenuItem(actions.get(DefaultEditorKit.pasteAction));
		miPaste.setText("Paste");
		miPaste.setAccelerator(isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_MASK) : KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK));
		add(miPaste);

		miSelectAll = new JMenuItem(actions.get(DefaultEditorKit.selectAllAction));
		miSelectAll.setText("Select All");
		miSelectAll.setAccelerator(isMac ? KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_MASK) : KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK));
		add(miSelectAll);

	}
 
Example 18
Source File: OutlineComponent.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create the PopupMenu actions correlating to a specific tree node.
 *
 * @param aNode	  - the node
 * @param aMenu	  - the menu to add the actions to
 * @param aRecursive - recursive
 */
private void initializeActionsFor(final DefaultMutableTreeNode aNode,
								  JPopupMenu aMenu, boolean aRecursive) {

	Object theUserObject = aNode.getUserObject();

	if (!aRecursive) {
		JMenuItem theExpandAllItem = new JMenuItem();
		theExpandAllItem.setText(getResourceHelper().getFormattedText(
				ERDesignerBundle.EXPANDALL));
		theExpandAllItem.addActionListener(e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode
                   .getPath()), true));
		aMenu.add(theExpandAllItem);

		JMenuItem theCollapseAllItem = new JMenuItem();
		theCollapseAllItem.setText(getResourceHelper().getFormattedText(
				ERDesignerBundle.COLLAPSEALL));
		theCollapseAllItem.addActionListener(e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode
                   .getPath()), false));

		aMenu.add(theCollapseAllItem);
		aMenu.addSeparator();
	}

	List<ModelItem> theItemList = new ArrayList<>();
	if (theUserObject instanceof ModelItem) {
		theItemList.add((ModelItem) theUserObject);
		ContextMenuFactory.addActionsToMenu(ERDesignerComponent.getDefault().getEditor(), aMenu, theItemList);
	}

	if (aNode.getParent() != null) {
		initializeActionsFor((DefaultMutableTreeNode) aNode.getParent(),
				aMenu, true);
	}
}
 
Example 19
Source File: GuiMouseListener.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
private void addPropertiesMenu(JPopupMenu menu, WorldObject worldObject) {
	if (Boolean.getBoolean("DEBUG")) {
		JMenu debugMenu = MenuFactory.createJMenu("Debug", imageInfoReader, soundIdReader);
		menu.add(debugMenu);
		
		JMenuItem guiPropertiesItem = MenuFactory.createJMenuItem(new GuiShowPropertiesAction(worldObject), soundIdReader);
		guiPropertiesItem.setText("Properties...");
		debugMenu.add(guiPropertiesItem);
		
		JMenuItem guiShowCommonersOverviewItem = MenuFactory.createJMenuItem(new GuiShowCommonersOverviewAction(world), soundIdReader);
		guiShowCommonersOverviewItem.setText("Show Commoners Overview...");
		debugMenu.add(guiShowCommonersOverviewItem);
		
		JMenuItem guiShowEconomicOverviewItem = MenuFactory.createJMenuItem(new GuiShowEconomicOverviewAction(world), soundIdReader);
		guiShowEconomicOverviewItem.setText("Show Economic Overview...");
		debugMenu.add(guiShowEconomicOverviewItem);
		
		JMenuItem guiShowSkillOverviewItem = MenuFactory.createJMenuItem(new GuiShowSkillOverviewAction(world), soundIdReader);
		guiShowSkillOverviewItem.setText("Show Skill Overview...");
		debugMenu.add(guiShowSkillOverviewItem);
		
		JMenuItem guiShowPersonalityOverviewItem = MenuFactory.createJMenuItem(new GuiShowPersonalitiesOverviewAction(world), soundIdReader);
		guiShowPersonalityOverviewItem.setText("Show Personality Overview...");
		debugMenu.add(guiShowPersonalityOverviewItem);
		
		JMenuItem guiShowReasonsOverviewItem = MenuFactory.createJMenuItem(new GuiShowReasonsOverviewAction(world), soundIdReader);
		guiShowReasonsOverviewItem.setText("Show Reasons Overview...");
		debugMenu.add(guiShowReasonsOverviewItem);
		
		JMenuItem guiShowPerformedActionsItem = MenuFactory.createJMenuItem(new GuiShowPerformedActionsAction(world), soundIdReader);
		guiShowPerformedActionsItem.setText("Show history items...");
		debugMenu.add(guiShowPerformedActionsItem);
		
		JMenuItem guiShowBuildingsItem = MenuFactory.createJMenuItem(new GuiShowBuildingsOverviewAction(world), soundIdReader);
		guiShowBuildingsItem.setText("Show buildings...");
		debugMenu.add(guiShowBuildingsItem);

		JMenuItem guiShowThrownOutOfGroupEventsAction = MenuFactory.createJMenuItem(new GuiShowThrownOutOfGroupEventsAction(), soundIdReader);
		guiShowThrownOutOfGroupEventsAction.setText("Show thrown out of group events...");
		debugMenu.add(guiShowThrownOutOfGroupEventsAction);
		
		JMenuItem guiShowElectionEventsAction = MenuFactory.createJMenuItem(new GuiShowElectionResultsAction(), soundIdReader);
		guiShowElectionEventsAction.setText("Show election events...");
		debugMenu.add(guiShowElectionEventsAction);
		
		JMenuItem guiShowImagesAction = MenuFactory.createJMenuItem(new GuiShowImagesOverviewAction(imageInfoReader), soundIdReader);
		guiShowImagesAction.setText("Show images...");
		debugMenu.add(guiShowImagesAction);		

		JMenuItem guiShowGoalDescriptionAction = MenuFactory.createJMenuItem(new GuiShowGoalDescriptionOverviewAction(imageInfoReader), soundIdReader);
		guiShowGoalDescriptionAction.setText("Show goal descriptions...");
		debugMenu.add(guiShowGoalDescriptionAction);
		
		JMenuItem guiShowBrawlFinishedAction = MenuFactory.createJMenuItem(new GuiShowBrawlFinishedAction(worldObject, playerCharacter, imageInfoReader, soundIdReader, container, world, parentFrame), soundIdReader);
		guiShowBrawlFinishedAction.setText("Show brawl finished dialog...");
		debugMenu.add(guiShowBrawlFinishedAction);
		
		JMenuItem guiShowDrinkingContestFinishedAction = MenuFactory.createJMenuItem(new GuiShowDrinkingContestFinishedAction(worldObject, playerCharacter, imageInfoReader, soundIdReader, container, world, parentFrame), soundIdReader);
		guiShowDrinkingContestFinishedAction.setText("Show drinking contest finished dialog...");
		debugMenu.add(guiShowDrinkingContestFinishedAction);
		
		JMenuItem guiShowExplorationOverviewAction = MenuFactory.createJMenuItem(new GuiShowExplorationOverviewAction(container, world), soundIdReader);
		guiShowExplorationOverviewAction.setText("Show exploration dialog...");
		debugMenu.add(guiShowExplorationOverviewAction);
	}
}
 
Example 20
Source File: MainMenu.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
private void changeDefaultIntervalName() {
    // Intervals -> All Data
    JMenuItem item = this.getMenu(2).getItem(0);
    item.setText(TimeFormatCache.formatInterval(Interval.DEFAULT));
}