javax.swing.event.MenuListener Java Examples

The following examples show how to use javax.swing.event.MenuListener. 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: bug4983388.java    From dragonwell8_jdk with 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 File: bug4983388.java    From TencentKona-8 with 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 File: bug4983388.java    From jdk8u60 with 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 File: bug4983388.java    From openjdk-jdk8u with 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
Source File: bug4983388.java    From openjdk-jdk8u-backup with 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 #6
Source File: bug4983388.java    From openjdk-jdk9 with 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 File: JMenuOperator.java    From openjdk-jdk9 with 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 File: JMenuOperator.java    From openjdk-jdk9 with 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 File: bug4983388.java    From jdk8u-jdk with 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 File: NameSet.java    From audiveris with 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 File: bug4983388.java    From hottub with 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 File: bug4983388.java    From openjdk-8-source with 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 File: bug4983388.java    From openjdk-8 with 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 File: bug4983388.java    From jdk8u_jdk with 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 File: bug4983388.java    From jdk8u-jdk with 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 File: bug4983388.java    From jdk8u-dev-jdk with 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);
}