Example usage for javax.swing JMenu add

List of usage examples for javax.swing JMenu add

Introduction

In this page you can find the example usage for javax.swing JMenu add.

Prototype

public JMenuItem add(Action a) 

Source Link

Document

Creates a new menu item attached to the specified Action object and appends it to the end of this menu.

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);//from   w ww.  j av  a 2s .c  o m

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    menu.add(new JMenuItem("Exit"));

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    MenuListener[] c = menu.getMenuListeners();

}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);//from w  w  w  .j  a v a2  s . c o  m

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    menu.add(new JMenuItem("Exit"));

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    Component[] c = menu.getMenuComponents();

}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);/* w ww . ja  v  a  2  s  .c  o  m*/

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    JMenuItem item = new JMenuItem("Exit");

    menu.add(item);

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    menu.remove(0);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);/*from w  w  w  .ja v  a2  s.co  m*/

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    JMenuItem item = new JMenuItem("Exit");

    menu.add(item);

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    menu.removeAll();
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);/*from  w  ww  .  j a va 2  s  . c o  m*/

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    JMenuItem item = new JMenuItem("Exit");

    menu.add(item);

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    menu.remove(item);
}

From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java

private JMenu createPopupMenu() {
    JMenu result = new JMenu();
    result.add(newExportMenu());

    return result;
}

From source file:com.planetmayo.debrief.satc.util.StraightLineCullingTestForm.java

private void createMenu() {
    JMenu menu = new JMenu("File");
    menu.add(new AbstractAction("Load") {
        private static final long serialVersionUID = 1L;

        @Override//  w w w  . ja  va 2s . co m
        public void actionPerformed(ActionEvent e) {
            if (fc.showOpenDialog(StraightLineCullingTestForm.this) == JFileChooser.APPROVE_OPTION) {
                try {
                    loadFile(fc.getSelectedFile());
                } catch (IOException ex) {
                }
            }
        }
    });

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(menu);
    setJMenuBar(menuBar);
}

From source file:FramewithAboutMenu.java

public FramewithAboutMenu(String title) {
    JMenuBar menuBar = new JMenuBar();
    setTitle(title);/*from   w w w .  j  a  v  a 2s  . co  m*/
    setJMenuBar(menuBar);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JMenu fileMenu = new JMenu("File");
    JMenu elementMenu = new JMenu("Elements");
    JMenu helpMenu = new JMenu("Help");
    fileMenu.setMnemonic('F');
    elementMenu.setMnemonic('E');
    helpMenu.setMnemonic('H');
    JMenuItem aboutItem = new JMenuItem("About");
    helpMenu.add(aboutItem);
    menuBar.add(helpMenu);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);/*from www  .  j a  v  a 2s .  c  o  m*/

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    menu.add(new AbstractAction("Exit") {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            System.out.println("action");

        }

    });

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new JMenuBar();
    JMenu menu = new JMenu("File");
    ComponentOrientation ori = ComponentOrientation.LEFT_TO_RIGHT;

    menu.applyComponentOrientation(ori);
    bar.add(menu);//from  w  ww. jav  a  2 s  .  c  o  m

    menu.add(new JMenuItem("Close"));
    menu.add(new JSeparator()); // SEPARATOR
    menu.add(new JMenuItem("Exit"));

    setJMenuBar(bar);
    add(new JLabel("A placeholder"));

    pack();
    setSize(300, 300);
    setVisible(true);

    menu.insert(new AbstractAction("Action") {

        @Override
        public void actionPerformed(ActionEvent arg0) {

        }

    }, 0);
}