Java Code Examples for javax.swing.event.MenuListener

The following examples show how to use javax.swing.event.MenuListener. These examples are extracted from open source projects. 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 Project: dragonwell8_jdk   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 2
Source Project: TencentKona-8   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 3
Source Project: jdk8u60   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 4
Source Project: openjdk-jdk8u   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 5
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 6
Source Project: openjdk-jdk9   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 7
Source Project: openjdk-jdk9   Source File: JMenuOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JMenu.addMenuListener(MenuListener)} through queue
 */
public void addMenuListener(final MenuListener menuListener) {
    runMapping(new MapVoidAction("addMenuListener") {
        @Override
        public void map() {
            ((JMenu) getSource()).addMenuListener(menuListener);
        }
    });
}
 
Example 8
Source Project: openjdk-jdk9   Source File: JMenuOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JMenu.removeMenuListener(MenuListener)} through queue
 */
public void removeMenuListener(final MenuListener menuListener) {
    runMapping(new MapVoidAction("removeMenuListener") {
        @Override
        public void map() {
            ((JMenu) getSource()).removeMenuListener(menuListener);
        }
    });
}
 
Example 9
Source Project: jdk8u-jdk   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 10
Source Project: audiveris   Source File: NameSet.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source Project: hottub   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 12
Source Project: openjdk-8-source   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 13
Source Project: openjdk-8   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 14
Source Project: jdk8u_jdk   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 15
Source Project: jdk8u-jdk   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}
 
Example 16
Source Project: jdk8u-dev-jdk   Source File: bug4983388.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.setMnemonic('F');
    menuBar.add(menu);
    JFrame frame = new JFrame();
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setVisible(true);
    MenuListener listener = new TestMenuListener();
    menu.addMenuListener(listener);
}