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

The following examples show how to use javax.swing.JMenu#setName() . 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: SwingSet3.java    From littleluck with Apache License 2.0 6 votes vote down vote up
protected JMenu createLookAndFeelMenu() {
        JMenu menu = new LuckMenu();
        menu.setOpaque(true);
//        menu.setBackground(Color.white);
        menu.setName("lookAndFeel");
        
        // Look for toolkit look and feels first
        UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels();
        lookAndFeel = UIManager.getLookAndFeel().getClass().getName();
        lookAndFeelRadioGroup = new ButtonGroup();
        for(UIManager.LookAndFeelInfo lafInfo: lookAndFeelInfos) {
            menu.add(createLookAndFeelItem(lafInfo.getName(), lafInfo.getClassName()));
        }  
        // Now load any look and feels defined externally as service via java.util.ServiceLoader
        LOOK_AND_FEEL_LOADER.iterator();
        for (LookAndFeel laf : LOOK_AND_FEEL_LOADER) {           
            menu.add(createLookAndFeelItem(laf.getName(), laf.getClass().getName()));
        }
         
        return menu;
    }
 
Example 2
Source File: SwingSet3.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
protected JMenu createLookAndFeelMenu() {
    JMenu menu = new JMenu();
    menu.setName("lookAndFeel");
    
    // Look for toolkit look and feels first
    UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels();
    lookAndFeel = UIManager.getLookAndFeel().getClass().getName();
    lookAndFeelRadioGroup = new ButtonGroup();
    for(UIManager.LookAndFeelInfo lafInfo: lookAndFeelInfos) {
        menu.add(createLookAndFeelItem(lafInfo.getName(), lafInfo.getClassName()));
    }  
    // Now load any look and feels defined externally as service via java.util.ServiceLoader
    LOOK_AND_FEEL_LOADER.iterator();
    for (LookAndFeel laf : LOOK_AND_FEEL_LOADER) {           
        menu.add(createLookAndFeelItem(laf.getName(), laf.getClass().getName()));
    }
     
    return menu;
}
 
Example 3
Source File: MainWindow.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JMenu addSubMenu(String id, JMenu parentMenu, PopupMenuListener popupListener) {
	JMenu menu = new JMenu(StringResource.get(id));
	menu.setName(id);
	menu.setFont(FontResource.getNormalFont());
	// menu.setForeground(ColorResource.getLightFontColor());
	menu.addActionListener(this);
	// menu.setBackground(ColorResource.getDarkerBgColor());
	menu.setBorderPainted(false);
	menu.getPopupMenu().addPopupMenuListener(popupListener);
	parentMenu.add(menu);
	return menu;
}
 
Example 4
Source File: AbstractMenuFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenu createMenu (String containerContext) {
    System.err.println("Creating a menu: " + containerContext);
    JMenu result = new JMenu();
    result.putClientProperty (KEY_CONTAINERCONTEXT, containerContext);
    result.setName(containerContext);
    result.setText (getEngine().getContainerProvider().getDisplayName(
        ContainerProvider.TYPE_MENU, containerContext));
    populateMenu(containerContext, result); //XXX listener should do this
    attachToMenu(result);
    return result;
}
 
Example 5
Source File: SampleBrowser.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Build the menu bar for SampleBrowser frame.
 *
 * @return the populated menu bar
 */
private JMenuBar buildMenuBar ()
{
    JMenuBar menuBar = new JMenuBar();
    JMenu repoMenu = new JMenu();
    repoMenu.setName("SampleBrowserRepoMenu");
    menuBar.add(repoMenu);
    ApplicationActionMap actionMap = OmrGui.getApplication().getContext().getActionMap(this);
    // Refresh viewer
    repoMenu.add(new JMenuItem(actionMap.get("refresh")));
    // Load sheet images
    repoMenu.add(new JMenuItem(actionMap.get("loadImages")));
    repoMenu.addSeparator(); // -----------------------
    // Check for sample duplicates/conflicts
    repoMenu.add(new JMenuItem(actionMap.get("checkRepository")));
    if (SampleRepository.USE_TRIBES) {
        // Check for tribes classification
        repoMenu.add(new JMenuItem(actionMap.get("checkTribes")));
    }
    repoMenu.addSeparator(); // -----------------------
    if (repository.isGlobal()) {
        // Launch trainer
        repoMenu.add(new JMenuItem(actionMap.get("launchTrainer")));
    } else {
        // Push local repository to global repository
        repoMenu.add(new JMenuItem(actionMap.get("pushRepository")));
    }
    repoMenu.addSeparator(); // -----------------------
    // Save repository
    repoMenu.add(new JMenuItem(actionMap.get("save")));
    // Export to CSV file
    repoMenu.add(new JMenuItem(actionMap.get("exportFeatures")));
    repoMenu.addSeparator(); // -----------------------
    // Purge sheets
    repoMenu.add(new JMenuItem(actionMap.get("purgeSheets")));
    //        // Shrink the whole repository
    //        repoMenu.add(new JMenuItem((ApplicationAction) actionMap.get("shrinkRepository")));
    //
    return menuBar;
}
 
Example 6
Source File: SwingSet3.java    From littleluck with Apache License 2.0 5 votes vote down vote up
protected JMenuBar createMenuBar() {

    JMenuBar menubar = new JMenuBar();
    menubar.setName("menubar");
    
    // File menu
    JMenu fileMenu = new JMenu();
    fileMenu.setName("file");
    menubar.add(fileMenu);
    
    // File -> Quit
    if (!runningOnMac()) {
        JMenuItem quitItem = new LuckMenuItem();
        quitItem.setOpaque(true);
        quitItem.setName("quit");
        quitItem.setAction(getAction("quit"));
        fileMenu.add(quitItem);
    }
   
    // View menu
    JMenu viewMenu = new JMenu();
    viewMenu.setName("view");
    // View -> Look and Feel       
    viewMenu.add(createLookAndFeelMenu());
    // View -> Source Code Visible
    sourceCodeCheckboxItem = new LuckCheckBoxMenuItem();
    sourceCodeCheckboxItem.setSelected(isSourceCodeVisible());
    sourceCodeCheckboxItem.setName("sourceCodeCheckboxItem");
    sourceCodeCheckboxItem.addChangeListener(new SourceVisibilityChangeListener());
    viewMenu.add(sourceCodeCheckboxItem);
    menubar.add(viewMenu);

    return menubar;
}
 
Example 7
Source File: SwingSet3.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
protected JMenuBar createMenuBar() {

    JMenuBar menubar = new JMenuBar();
    menubar.setName("menubar");
    
    // File menu
    JMenu fileMenu = new JMenu();
    fileMenu.setName("file");
    menubar.add(fileMenu);
    
    // File -> Quit
    if (!runningOnMac()) {
        JMenuItem quitItem = new JMenuItem();
        quitItem.setName("quit");
        quitItem.setAction(getAction("quit"));
        fileMenu.add(quitItem);
    }
   
    // View menu
    JMenu viewMenu = new JMenu();
    viewMenu.setName("view");
    // View -> Look and Feel       
    viewMenu.add(createLookAndFeelMenu());
    // View -> Source Code Visible
    sourceCodeCheckboxItem = new JCheckBoxMenuItem();
    sourceCodeCheckboxItem.setSelected(isSourceCodeVisible());
    sourceCodeCheckboxItem.setName("sourceCodeCheckboxItem");
    sourceCodeCheckboxItem.addChangeListener(new SourceVisibilityChangeListener());
    viewMenu.add(sourceCodeCheckboxItem);
    menubar.add(viewMenu);

    return menubar;
}
 
Example 8
Source File: ActionManager.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Register all actions as listed in the descriptor files, and organize them
 * according to the various domains defined.
 * There is one pull-down menu generated for each domain found.
 */
public void registerAllActions ()
{
    // Insert an initial separator, to let user easily grab the toolBar
    toolBar.addSeparator();

    DomainLoop:
    for (String domain : Actions.getDomainNames()) {
        // Create dedicated menu for this range, if not already existing
        JMenu menu = menuMap.get(domain);

        if (menu == null) {
            logger.debug("Creating menu:{}", domain);
            menu = new SeparableMenu(domain);
            menuMap.put(domain, menu);
        } else {
            logger.debug("Augmenting menu:{}", domain);
        }

        // Proper menu decoration
        ResourceMap resource = OmrGui.getApplication().getContext().getResourceMap(
                Actions.class);
        menu.setText(domain); // As default
        menu.setName(domain);

        // Register all actions in the given domain
        registerDomainActions(domain, menu);
        resource.injectComponents(menu); // Localized

        SeparableMenu.trimSeparator(menu); // No separator at end of menu

        // Smart insertion of the menu into the menu bar, and separators into the toolBar
        if (menu.getItemCount() > 0) {
            final int toolCount = toolBar.getComponentCount();

            if (toolCount > 0) {
                Component comp = toolBar.getComponent(toolCount - 1);

                if (!(comp instanceof JToolBar.Separator)) {
                    toolBar.addSeparator();
                }
            }

            menuBar.add(menu);
        }
    }
}
 
Example 9
Source File: ActionManager.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Register all actions as listed in the descriptor files, and
 * organize them according to the various domains defined.
 * There is one pull-down menu generated for each domain found.
 */
public void registerAllActions ()
{
    // Insert an initial separator, to let user easily grab the toolBar
    toolBar.addSeparator();

    for (String domain : Actions.getDomainNames()) {
        // Create dedicated menu for this range, if not already existing
        JMenu menu = menuMap.get(domain);

        if (menu == null) {
            logger.debug("Creating menu:{}", domain);
            menu = new SeparableMenu(domain);
            menuMap.put(domain, menu);
        } else {
            logger.debug("Augmenting menu:{}", domain);
        }

        // Proper menu decoration
        ResourceMap resource = MainGui.getInstance().getContext().
                getResourceMap(Actions.class);
        menu.setText(domain); // As default
        menu.setName(domain);

        // Register all actions in the given domain
        registerDomainActions(domain, menu);
        resource.injectComponents(menu);

        toolBar.addSeparator();

        // Smart insertion of the menu into the menu bar
        if (menu.getItemCount() > 0) {
            if (domain.equalsIgnoreCase("help")) {
                menuBar.add(Box.createHorizontalStrut(50));
            }

            SeparableMenu.trimSeparator(menu); // No separator at end
            menuBar.add(menu);
        }
    }
}