Java Code Examples for javax.swing.JMenu#setToolTipText()

The following examples show how to use javax.swing.JMenu#setToolTipText() . 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: PCGenMenuBar.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private JMenu createSourcesMenu()
{
	JMenu menu = new JMenu();
	menu.setText(LanguageBundle.getString("in_mnuSources"));
	menu.setToolTipText(LanguageBundle.getString("in_mnuSourcesTip"));
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOURCES_LOAD_SELECT_COMMAND)));
	menu.addSeparator();
	menu.add(new QuickSourceMenu());
	menu.addSeparator();
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOURCES_RELOAD_COMMAND)));
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOURCES_UNLOAD_COMMAND)));
	menu.addSeparator();
	menu.add(actionMap.get(PCGenActionMap.INSTALL_DATA_COMMAND));

	return menu;
}
 
Example 2
Source File: SendingHardwareManager.java    From IrScrutinizer with GNU General Public License v3.0 6 votes vote down vote up
private void createMenu(String selection) {
    menu = new JMenu();
    menu.setText("Transmitting Hardware");
    menu.setToolTipText("Allows direct selection of transmitting hardware");
    buttonGroup = new ButtonGroup();
    table.entrySet().stream().map((kvp) -> {
        String name = kvp.getKey();
        final ISendingHardware<?> hardware = kvp.getValue();
        JRadioButton menuItem = new JRadioButton(name);
        menuItem.setSelected(name.equals(selection));
        //portRadioButtons[i] = menuItem;
        menuItem.addActionListener((java.awt.event.ActionEvent evt) -> {
            try {
                select(hardware);
            } catch (HarcHardwareException ex) {
                guiUtils.error(ex);
            }
        });
        return menuItem;
    }).map((menuItem) -> {
        buttonGroup.add(menuItem);
        return menuItem;
    }).forEachOrdered((menuItem) -> {
        menu.add(menuItem);
    });
}
 
Example 3
Source File: ExportFormatManager.java    From IrScrutinizer with GNU General Public License v3.0 6 votes vote down vote up
private void createMenu(String selection) {
    menu = new JMenu();
    menu.setText("Export formats");
    menu.setToolTipText("Allows direct selection of export format");
    buttonGroup = new ButtonGroup();
    for (String formatName : toArray()) {
        final String name = formatName;
        JMenuItem menuItem = new JCheckBoxMenuItem(name);
        menuItem.setSelected(name.equals(selection));
        menuItem.addActionListener((java.awt.event.ActionEvent evt) -> {
            exportFormatSelector.select(name);
        });

        buttonGroup.add(menuItem);
        menu.add(menuItem);
    }
}
 
Example 4
Source File: CapturingHardwareManager.java    From IrScrutinizer with GNU General Public License v3.0 6 votes vote down vote up
private void createMenu(String selection) {
    menu = new JMenu();
    menu.setText("Capturing Hardware");
    menu.setToolTipText("Allows direct selection of capturing hardware");
    buttonGroup = new ButtonGroup();
    table.entrySet().stream().map((kvp) -> {
        String name = kvp.getKey();
        final ICapturingHardware<?> hardware = kvp.getValue();
        JRadioButton menuItem = new JRadioButton(name);
        menuItem.setSelected(name.equals(selection));
        //portRadioButtons[i] = menuItem;
        menuItem.addActionListener((java.awt.event.ActionEvent evt) -> {
            try {
                select(hardware);
            } catch (IOException | HarcHardwareException ex) {
                guiUtils.error(ex);
            }
        });
        return menuItem;
    }).map((menuItem) -> {
        buttonGroup.add(menuItem);
        return menuItem;
    }).forEachOrdered((menuItem) -> {
        menu.add(menuItem);
    });
}
 
Example 5
Source File: PCGenMenuBar.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private JMenu createSourcesMenu()
{
	JMenu menu = new JMenu();
	menu.setText(LanguageBundle.getString("in_mnuSources"));
	menu.setToolTipText(LanguageBundle.getString("in_mnuSourcesTip"));
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOURCES_LOAD_SELECT_COMMAND)));
	menu.addSeparator();
	menu.add(new QuickSourceMenu());
	menu.addSeparator();
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOURCES_RELOAD_COMMAND)));
	menu.add(new JMenuItem(actionMap.get(PCGenActionMap.SOURCES_UNLOAD_COMMAND)));
	menu.addSeparator();
	menu.add(actionMap.get(PCGenActionMap.INSTALL_DATA_COMMAND));

	return menu;
}
 
Example 6
Source File: SampleController.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Create an {@code AssignAction} object.
 */
public AssignAction ()
{
    super("Assign to...");
    putValue(javax.swing.Action.SHORT_DESCRIPTION, "Assign a new shape");
    ShapeSet.addAllShapes(popup, actionListener);

    // Build menu for SamplePopup
    menu = new JMenu("Assign to");
    ShapeSet.addAllShapes(menu, actionListener);
    menu.setToolTipText("Assign a new shape");
}
 
Example 7
Source File: IrPlotter.java    From IrScrutinizer with GNU General Public License v3.0 5 votes vote down vote up
private void initializePlotterWidthsMenu() {
    plotterWidthsMenu = new JMenu();//.removeAll();
    plotterWidthsMenu.setText("Set width");
    plotterWidthsMenu.setToolTipText("Set width of the plotter explicitly. It can then be horizontally scrolled.");
    for (int width : plotterWidths) {
        JMenuItem menuItem = new JMenuItem(Integer.toString(width));
        final int localWidth = width;
        menuItem.addActionListener((java.awt.event.ActionEvent evt) -> {
            //properties.setPlotterWidth(localWidth);
            setWidth(localWidth);
        });

        plotterWidthsMenu.add(menuItem);
    }
}
 
Example 8
Source File: PreviewPaneUtilities.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static JMenu createMenu( final ActionCategory cat ) {
  final JMenu menu = new JMenu();
  menu.setText( cat.getDisplayName() );
  final Integer mnemonicKey = cat.getMnemonicKey();
  if ( mnemonicKey != null ) {
    menu.setMnemonic( mnemonicKey.intValue() );
  }
  final String toolTip = cat.getShortDescription();
  if ( toolTip != null && toolTip.length() > 0 ) {
    menu.setToolTipText( toolTip );
  }
  return menu;
}
 
Example 9
Source File: BlazeActions.java    From constellation with Apache License 2.0 4 votes vote down vote up
public BlazeActions() {
    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    menu = new JMenu();
    menu.setIcon(ImageUtilities.loadImageIcon(BLAZE_ACTIONS_ICON, false));
    menu.setToolTipText("Blaze Controls");
    menu.addChangeListener(e -> {
        if (graph != null) {
            updateSliders(graph);
        }
    });
    menu.setEnabled(false);

    final JMenuItem selectBlazesItem = new JMenuItem("Select Blazes");
    selectBlazesItem.setIcon(ImageUtilities.loadImageIcon(SELECT_BLAZES_ICON, false));
    selectBlazesItem.setActionCommand(SELECT_BLAZES_ACTION);
    selectBlazesItem.addActionListener(this);
    menu.add(selectBlazesItem);

    final JMenuItem deselectBlazesItem = new JMenuItem("Deselect Blazes");
    deselectBlazesItem.setIcon(ImageUtilities.loadImageIcon(DESELECT_BLAZES_ICON, false));
    deselectBlazesItem.setActionCommand(DESELECT_BLAZES_ACTION);
    deselectBlazesItem.addActionListener(this);
    menu.add(deselectBlazesItem);

    final JMenuItem addBlueBlazeItem = new JMenuItem("Add Blue Blazes");
    addBlueBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_BLUE_BLAZE_ICON, false));
    addBlueBlazeItem.setActionCommand(ADD_BLUE_BLAZE_ACTION);
    addBlueBlazeItem.addActionListener(BlazeActions.this);
    menu.add(addBlueBlazeItem);

    final JMenuItem addRedBlazeItem = new JMenuItem("Add Red Blazes");
    addRedBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_RED_BLAZE_ICON, false));
    addRedBlazeItem.setActionCommand(ADD_RED_BLAZE_ACTION);
    addRedBlazeItem.addActionListener(BlazeActions.this);
    menu.add(addRedBlazeItem);

    final JMenuItem addYellowBlazeItem = new JMenuItem("Add Yellow Blazes");
    addYellowBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_YELLOW_BLAZE_ICON, false));
    addYellowBlazeItem.setActionCommand(ADD_YELLOW_BLAZE_ACTION);
    addYellowBlazeItem.addActionListener(BlazeActions.this);
    menu.add(addYellowBlazeItem);

    final JMenuItem colorBlazeItem = new JMenuItem("Add Custom Blazes");
    colorBlazeItem.setIcon(ImageUtilities.loadImageIcon(ADD_CUSTOM_BLAZE_ICON, false));
    colorBlazeItem.setActionCommand(ADD_CUSTOM_BLAZE_ACTION);
    colorBlazeItem.addActionListener(BlazeActions.this);
    menu.add(colorBlazeItem);

    final JMenuItem removeBlazeItem = new JMenuItem("Remove Blazes");
    removeBlazeItem.setIcon(ImageUtilities.loadImageIcon(REMOVE_BLAZE_ICON, false));
    removeBlazeItem.setActionCommand(REMOVE_BLAZES_ACTION);
    removeBlazeItem.addActionListener(BlazeActions.this);
    menu.add(removeBlazeItem);

    this.sizeSlider = new SliderMenuItem("Size");
    sizeSlider.setValue((NbPreferences.forModule(GraphPreferenceKeys.class)
            .getInt(GraphPreferenceKeys.BLAZE_SIZE, GraphPreferenceKeys.BLAZE_SIZE_DEFAULT)));
    menu.add(sizeSlider);

    this.opacitySlider = new SliderMenuItem("Opacity");
    opacitySlider.setValue((NbPreferences.forModule(GraphPreferenceKeys.class)
            .getInt(GraphPreferenceKeys.BLAZE_OPACITY, GraphPreferenceKeys.BLAZE_OPACITY_DEFAULT)));
    menu.add(opacitySlider);

    this.sliderChangeListener = e
            -> setBlazeProperties(sizeSlider.getValue() / 100f, opacitySlider.getValue() / 100f);
    sizeSlider.addChangeListener(sliderChangeListener);
    opacitySlider.addChangeListener(sliderChangeListener);

    menuBar.add(menu);
    panel.add(menuBar, BorderLayout.CENTER);

    GraphManager.getDefault().addGraphManagerListener(BlazeActions.this);
}
 
Example 10
Source File: DimActions.java    From constellation with Apache License 2.0 4 votes vote down vote up
public DimActions() {
    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    menu = new JMenu();
    menu.setIcon(ImageUtilities.loadImageIcon(DIM_ACTIONS_ICON, false));
    menu.setToolTipText("Dim Controls");
    menu.setEnabled(false);

    final JMenuItem dimSelectedItem = new JMenuItem("Dim Selected");
    dimSelectedItem.setIcon(ImageUtilities.loadImageIcon(DIM_SELECTED_ICON, false));
    dimSelectedItem.setActionCommand(DIM_SELECTED_ACTION);
    dimSelectedItem.addActionListener(DimActions.this);
    menu.add(dimSelectedItem);

    final JMenuItem dimUnselectedItem = new JMenuItem("Dim Unselected");
    dimUnselectedItem.setIcon(ImageUtilities.loadImageIcon(DIM_UNSELECTED_ICON, false));
    dimUnselectedItem.setActionCommand(DIM_UNSELECTED_ACTION);
    dimUnselectedItem.addActionListener(DimActions.this);
    menu.add(dimUnselectedItem);

    final JMenuItem dimAllItem = new JMenuItem("Dim All");
    dimAllItem.setIcon(ImageUtilities.loadImageIcon(DIM_ALL_ICON, false));
    dimAllItem.setActionCommand(DIM_ALL_ACTION);
    dimAllItem.addActionListener(DimActions.this);
    menu.add(dimAllItem);

    menu.add(new JSeparator(SwingConstants.HORIZONTAL));

    final JMenuItem undimSelectedItem = new JMenuItem("Undim Selected");
    undimSelectedItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_SELECTED_ICON, false));
    undimSelectedItem.setActionCommand(UNDIM_SELECTED_ACTION);
    undimSelectedItem.addActionListener(DimActions.this);
    menu.add(undimSelectedItem);

    final JMenuItem undimUnselectedItem = new JMenuItem("Undim Unselected");
    undimUnselectedItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_UNSELECTED_ICON, false));
    undimUnselectedItem.setActionCommand(UNDIM_UNSELECTED_ACTION);
    undimUnselectedItem.addActionListener(DimActions.this);
    menu.add(undimUnselectedItem);

    final JMenuItem undimAllItem = new JMenuItem("Undim All");
    undimAllItem.setIcon(ImageUtilities.loadImageIcon(UNDIM_ALL_ICON, false));
    undimAllItem.setActionCommand(UNDIM_ALL_ACTION);
    undimAllItem.addActionListener(DimActions.this);
    menu.add(undimAllItem);

    menu.add(new JSeparator(SwingConstants.HORIZONTAL));

    final JMenuItem selectDimmed = new JMenuItem("Select Dimmed");
    selectDimmed.setIcon(ImageUtilities.loadImageIcon(SELECT_DIMMED_ICON, false));
    selectDimmed.setActionCommand(SELECT_DIMMED_ACTION);
    selectDimmed.addActionListener(DimActions.this);
    menu.add(selectDimmed);

    final JMenuItem selectUndimmed = new JMenuItem("Select Undimmed");
    selectUndimmed.setIcon(ImageUtilities.loadImageIcon(SELECT_UNDIMMED_ICON, false));
    selectUndimmed.setActionCommand(SELECT_UNDIMMED_ACTION);
    selectUndimmed.addActionListener(DimActions.this);
    menu.add(selectUndimmed);

    menuBar.add(menu);
    panel.add(menuBar, BorderLayout.CENTER);

    GraphManager.getDefault().addGraphManagerListener(DimActions.this);
}
 
Example 11
Source File: HopActions.java    From constellation with Apache License 2.0 4 votes vote down vote up
public HopActions() {
    panel = new JPanel();
    panel.setLayout(new BorderLayout());

    menuBar = new JMenuBar();
    menuBar.setOpaque(true);

    menu = new JMenu();
    menu.setIcon(HOP_OUT_ONE_ICON);
    menu.setToolTipText("Hop Controls");
    menu.setEnabled(false);

    final JMenuItem hopOutHalfItem = new JMenuItem("Hop Out Half");
    hopOutHalfItem.setIcon(HOP_OUT_HALF_ICON);
    hopOutHalfItem.setActionCommand(HOP_OUT_HALF_ACTION);
    hopOutHalfItem.addActionListener(HopActions.this);
    menu.add(hopOutHalfItem);

    final JMenuItem hopOutOneItem = new JMenuItem("Hop Out One");
    hopOutOneItem.setIcon(HOP_OUT_ONE_ICON);
    hopOutOneItem.setActionCommand(HOP_OUT_ONE_ACTION);
    hopOutOneItem.addActionListener(HopActions.this);
    menu.add(hopOutOneItem);

    final JMenuItem hopOutFullItem = new JMenuItem("Hop Out Full");
    hopOutFullItem.setIcon(HOP_OUT_FULL_ICON);
    hopOutFullItem.setActionCommand(HOP_OUT_FULL_ACTION);
    hopOutFullItem.addActionListener(HopActions.this);
    menu.add(hopOutFullItem);

    final JPanel directionPanel = new JPanel();
    directionPanel.setLayout(new BoxLayout(directionPanel, BoxLayout.Y_AXIS));
    directionPanel.setBorder(new TitledBorder("Direction"));

    outgoing = new JCheckBox("Outgoing", true);
    outgoing.setToolTipText("Hop Along Outgoing Transactions");
    directionPanel.add(outgoing);

    incoming = new JCheckBox("Incoming", true);
    incoming.setToolTipText("Hop Along Incoming Transactions");
    directionPanel.add(incoming);

    undirected = new JCheckBox("Undirected", true);
    undirected.setToolTipText("Hop Along Undirected Transactions");
    directionPanel.add(undirected);

    final JPanel optionsPanel = new JPanel();
    optionsPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
    optionsPanel.setLayout(new BorderLayout());
    optionsPanel.add(directionPanel, BorderLayout.CENTER);

    menu.add(optionsPanel);

    menuBar.add(menu);
    panel.add(menuBar, BorderLayout.CENTER);

    GraphManager.getDefault().addGraphManagerListener(HopActions.this);
}
 
Example 12
Source File: RunScriptAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private RunScriptAction(Lookup context, JTextComponent editor, FileObject scriptOrFolder, 
        String name, String description) {
    this();
    this.context = context;
    this.editor = editor;
    this.storage = PersistentSnippetsSupport.create(context);
    this.scriptFile = scriptOrFolder;
    putValue(NAME, name);
    if (scriptFile == null) {
        putValue(SHORT_DESCRIPTION, Bundle.DESC_RunSavedScript());
        putValue(SMALL_ICON, ImageUtilities.loadImageIcon(RESOURCE_ICON, false));
    } else {
        putValue(SHORT_DESCRIPTION, description);
    }
    
    if (storage == null) {
        setEnabled(false);
        return;
    }
    
    boolean enabled = true;
    
    
    if (scriptOrFolder == null || scriptOrFolder.isFolder()) {
        if (scriptOrFolder == null) {
            popup = new JPopupMenu() {
                @Override
                public int getComponentCount() {
                    refresh();
                    return super.getComponentCount();
                }
            };
        } else {
            subMenu = new JMenu() {
                @Override
                public int getMenuComponentCount() {
                    refresh();
                    return super.getMenuComponentCount();
                }
            };
            subMenu.setText(name);
            subMenu.setToolTipText(description);
        }
        if (storage.getSavedClasses(null).isEmpty()) {
            setEnabled(false);
        }
        invalidate();
        if (scriptOrFolder != null) {
            FileChangeListener fcl = WeakListeners.create(FileChangeListener.class, listen, scriptOrFolder);
            scriptOrFolder.addFileChangeListener(fcl);
            weakListen = fcl;
        } else {
            ChangeListener cl = WeakListeners.change(listen, storage);
            storage.addChangeListener(cl);
            weakListen = cl;
        }
    }
}
 
Example 13
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the necessary <code>JMenuItem</code>s to the passed in menu.
 *
 * @param menu the menu
 */
private void addMenuItems(JMenu menu)
{
	Locale locale = getRootPane().getLocale();
	menu.setToolTipText(//"窗口相关操作.");
			UIManager.getString("BETitlePane.titleMenuToolTipText",getLocale()));

	JMenuItem mi;
	int mnemonic;
	if(getWindowDecorationStyle() == JRootPane.FRAME)//! 只有frame才有这些菜单项
	{
		mi = menu.add(restoreAction);
		mnemonic = BEUtils.getInt("MetalTitlePane.restoreMnemonic",-1);
		if (mnemonic != -1)
		{
			mi.setMnemonic(mnemonic);
		}

		mi = menu.add(iconifyAction);
		mnemonic = BEUtils.getInt("MetalTitlePane.iconifyMnemonic", -1);
		if (mnemonic != -1)
		{
			mi.setMnemonic(mnemonic);
		}

		if (Toolkit.getDefaultToolkit().isFrameStateSupported(
				Frame.MAXIMIZED_BOTH))
		{
			mi = menu.add(maximizeAction);
			mnemonic = BEUtils.getInt("MetalTitlePane.maximizeMnemonic",
					-1);
			if (mnemonic != -1)
			{
				mi.setMnemonic(mnemonic);
			}
		}

		menu.add(new JSeparator());
	}

	mi = menu.add(closeAction);
	mnemonic = BEUtils.getInt("MetalTitlePane.closeMnemonic", -1);
	if (mnemonic != -1)
	{
		mi.setMnemonic(mnemonic);
	}
}