javax.swing.JMenu#addMenuListener ( )源码实例Demo

下面列出了javax.swing.JMenu#addMenuListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: audiveris   文件: PluginsManager.java
/**
 * Report the concrete UI menu of all plugins
 *
 * @param menu a preallocated menu instance, or null
 * @return the populated menu entity
 */
public JMenu getMenu (JMenu menu)
{
    if (menu == null) {
        menu = new SeparableMenu();
    }

    for (Plugin plugin : plugins) {
        menu.add(new JMenuItem(new PluginAction(plugin)));
    }

    // Listener to modify attributes on-the-fly
    menu.addMenuListener(new MyMenuListener());

    this.menu = menu;

    return menu;
}
 
源代码2 项目: libreveris   文件: PluginsManager.java
/**
 * Report the concrete UI menu of all plugins
 *
 * @param menu a preallocated menu instance, or null
 * @return the populated menu entity
 */
public JMenu getMenu (JMenu menu)
{
    if (menu == null) {
        menu = new SeparableMenu();
    }

    for (Plugin plugin : map.values()) {
        menu.add(new JMenuItem(new PluginAction(plugin)));
    }

    // Listener to modify attributes on-the-fly
    menu.addMenuListener(new MyMenuListener());

    this.menu = menu;

    return menu;
}
 
源代码3 项目: openjdk-jdk9   文件: FigureWidget.java
public static void build(JPopupMenu menu, Figure figure, FigureWidget figureWidget, boolean successors, DiagramScene diagramScene) {
    Set<Figure> set = figure.getPredecessorSet();
    if (successors) {
        set = figure.getSuccessorSet();
    }

    boolean first = true;
    for (Figure f : set) {
        if (f == figure) {
            continue;
        }

        if (first) {
            first = false;
        } else {
            menu.addSeparator();
        }

        Action go = diagramScene.createGotoAction(f);
        menu.add(go);

        JMenu preds = new JMenu("Nodes Above");
        preds.addMenuListener(figureWidget.new NeighborMenuListener(preds, f, false));
        menu.add(preds);

        JMenu succs = new JMenu("Nodes Below");
        succs.addMenuListener(figureWidget.new NeighborMenuListener(succs, f, true));
        menu.add(succs);
    }

    if (figure.getPredecessorSet().isEmpty() && figure.getSuccessorSet().isEmpty()) {
        menu.add("(none)");
    }
}
 
源代码4 项目: audiveris   文件: NameSet.java
/**
 * Feed a menu with the dynamic content of this NameSet.
 *
 * @param menu         the menu to be fed, if null it is allocated by this method
 * @param itemListener the listener to be called on item selection
 * @return the menu properly dynamized
 */
public JMenu feedMenu (JMenu menu,
                       final ActionListener itemListener)
{
    final JMenu finalMenu = (menu != null) ? menu : new JMenu(setName);

    MenuListener menuListener = new AbstractMenuListener()
    {
        @Override
        public void menuSelected (MenuEvent e)
        {
            // Clean up the whole menu
            finalMenu.removeAll();

            // Rebuild the whole list of menu items on the fly
            synchronized (NameSet.this) {
                for (String f : names) {
                    JMenuItem menuItem = new JMenuItem(f);
                    menuItem.addActionListener(itemListener);
                    finalMenu.add(menuItem);
                }
            }
        }
    };

    // Listener to menu selection, to modify content on-the-fly
    finalMenu.addMenuListener(menuListener);

    return finalMenu;
}
 
源代码5 项目: libreveris   文件: DynamicMenu.java
/**
 * Create the dynamic menu.
 *
 * @param menuLabel the label to be used for the menu
 */
public DynamicMenu (String menuLabel)
{
    menu = new JMenu(menuLabel);

    // Listener to menu selection, to modify content on-the-fly
    menu.addMenuListener(listener);
}
 
源代码6 项目: libreveris   文件: DynamicMenu.java
/**
 * Creates a new DynamicMenu object.
 *
 * @param action related action
 */
public DynamicMenu (Action action)
{
    menu = new JMenu(action);

    // Listener to menu selection, to modify content on-the-fly
    menu.addMenuListener(listener);
}
 
源代码7 项目: netbeans   文件: AbstractMenuFactory.java
private void attachToMenu (JMenu menu) {
    menu.addContainerListener(getMenuListener());
    menu.addComponentListener(getMenuListener());
    menu.addMenuListener(getMenuListener());
}
 
源代码8 项目: gcs   文件: DynamicMenuEnabler.java
/** @param menu The {@link JMenu} to add. */
public static void add(JMenu menu) {
    menu.addMenuListener(INSTANCE);
}