Example usage for javax.swing JMenuItem setActionCommand

List of usage examples for javax.swing JMenuItem setActionCommand

Introduction

In this page you can find the example usage for javax.swing JMenuItem setActionCommand.

Prototype

public void setActionCommand(String actionCommand) 

Source Link

Document

Sets the action command for this button.

Usage

From source file:it.unibas.spicygui.controllo.provider.MyPopupSceneMatcher.java

private void createPopupMenuGlassPane() {
    popupMenu = new JPopupMenu("Popup menu");
    JMenuItem item;

    item = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.ACTION_SLIDER));
    item.setActionCommand(Costanti.ACTION_SLIDER);
    item.addActionListener(this);
    popupMenu.add(item);// w  w w.  ja  v  a 2 s  . co m

}

From source file:org.simbrain.plot.barchart.BarChartGui.java

/**
 * Creates the menu bar./*  w  w w. j ava  2  s  .c o  m*/
 */
private void createAttachMenuBar() {
    JMenuBar bar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");
    for (Action action : actionManager.getOpenSavePlotActions()) {
        fileMenu.add(action);
    }
    fileMenu.addSeparator();
    fileMenu.add(new CloseAction(this.getWorkspaceComponent()));

    JMenu editMenu = new JMenu("Edit");
    JMenuItem preferences = new JMenuItem("Preferences...");
    preferences.addActionListener(this);
    preferences.setActionCommand("dialog");
    editMenu.add(preferences);

    JMenu helpMenu = new JMenu("Help");
    ShowHelpAction helpAction = new ShowHelpAction("Pages/Plot/bar_chart.html");
    JMenuItem helpItem = new JMenuItem(helpAction);
    helpMenu.add(helpItem);

    bar.add(fileMenu);
    bar.add(editMenu);
    bar.add(helpMenu);

    getParentFrame().setJMenuBar(bar);
}

From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java

private JMenu createFileMenu() {
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');

    JMenuItem fileExit = new JMenuItem("Exit");
    fileExit.setMnemonic('x');
    fileExit.setActionCommand("exit");
    fileExit.addActionListener(actionMapper);
    fileMenu.add(fileExit);/*from w w w  . ja va2 s. c  o m*/

    return fileMenu;
}

From source file:TreeUtil.java

/** Creates the menus by using recursion */
public JMenuItem getMenus(DefaultMutableTreeNode node, JMenu parentMenu) {
    String name = node.getUserObject().toString();
    int numChild = node.getChildCount();
    if (numChild < 1) {
        JMenuItem tempMenu = new JMenuItem(name);
        tempMenu.setActionCommand(parentMenu.getActionCommand() + "." + name);
        tempMenu.addActionListener(this);
        return tempMenu;
    }/* www.jav  a2 s .  c om*/
    JMenu tempMenu = new JMenu(name);
    tempMenu.setActionCommand(parentMenu.getActionCommand() + "." + name);
    tempMenu.addActionListener(this);
    for (int i = 0; i < numChild; i++) {
        tempMenu.add(getMenus((DefaultMutableTreeNode) node.getChildAt(i), tempMenu));
    }
    return tempMenu;
}

From source file:org.simbrain.plot.scatterplot.ScatterPlotGui.java

/**
 * Creates the menu bar./*from w  w  w.  ja v a  2 s. co  m*/
 */
private void createAttachMenuBar() {
    JMenuBar bar = new JMenuBar();

    JMenu fileMenu = new JMenu("File");
    for (Action action : actionManager.getOpenSavePlotActions()) {
        fileMenu.add(action);
    }
    fileMenu.addSeparator();
    fileMenu.add(new CloseAction(this.getWorkspaceComponent()));

    JMenu editMenu = new JMenu("Edit");
    JMenuItem preferences = new JMenuItem("Preferences...");
    preferences.addActionListener(this);
    preferences.setActionCommand("dialog");
    editMenu.add(preferences);

    JMenu helpMenu = new JMenu("Help");
    ShowHelpAction helpAction = new ShowHelpAction("Pages/Plot/scatter_plot.html");
    JMenuItem helpItem = new JMenuItem(helpAction);
    helpMenu.add(helpItem);

    bar.add(fileMenu);
    bar.add(editMenu);
    bar.add(helpMenu);

    getParentFrame().setJMenuBar(bar);
}

From source file:it.unibas.spicygui.controllo.provider.composition.MyPopupProviderWidgetConstantComposition.java

private void createPopupMenu() {
    menu = new JPopupMenu("Popup menu");

    JMenuItem itemDeleteWidget;

    itemDeleteWidget = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.DELETE_WIDGET_COMPOSITION));
    itemDeleteWidget.setActionCommand(DELETE);
    itemDeleteWidget.addActionListener(this);
    menu.add(itemDeleteWidget);/*from   w  w w. j av a2s .c  om*/

}

From source file:InternalFrameDemo.java

protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    // Set up the lone menu.
    JMenu menu = new JMenu("Document");
    menu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(menu);/*ww  w  .ja v  a2s  .  c o m*/

    // Set up the first menu item.
    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("new");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    // Set up the second menu item.
    menuItem = new JMenuItem("Quit");
    menuItem.setMnemonic(KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK));
    menuItem.setActionCommand("quit");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    return menuBar;
}

From source file:com.alvermont.javascript.tools.shell.ShellJSConsole.java

public ShellJSConsole(String[] args) {
    super("Rhino JavaScript Console");

    final JMenuBar menubar = new JMenuBar();
    createFileChooser();//  ww  w.  ja  v a 2s. c  o m

    final String[] fileItems = { "Load...", "Close" };
    final String[] fileCmds = { "Load", "Close" };
    final char[] fileShortCuts = { 'L', 'X' };
    final String[] editItems = { "Cut", "Copy", "Paste" };
    final char[] editShortCuts = { 'T', 'C', 'P' };
    final JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    final JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic('E');

    for (int i = 0; i < fileItems.length; ++i) {
        final JMenuItem item = new JMenuItem(fileItems[i], fileShortCuts[i]);
        item.setActionCommand(fileCmds[i]);
        item.addActionListener(this);
        fileMenu.add(item);
    }

    for (int i = 0; i < editItems.length; ++i) {
        final JMenuItem item = new JMenuItem(editItems[i], editShortCuts[i]);
        item.addActionListener(this);
        editMenu.add(item);
    }

    final ButtonGroup group = new ButtonGroup();
    menubar.add(fileMenu);
    menubar.add(editMenu);
    setJMenuBar(menubar);
    this.consoleTextArea = new ShellConsoleTextArea(args);

    final JScrollPane scroller = new JScrollPane(this.consoleTextArea);
    setContentPane(scroller);
    this.consoleTextArea.setRows(24);
    this.consoleTextArea.setColumns(80);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            setVisible(false);
        }
    });
    pack();
    setVisible(true);
    // System.setIn(consoleTextArea.getIn());
    // System.setOut(consoleTextArea.getOut());
    // System.setErr(consoleTextArea.getErr());
    ShellMain.setIn(this.consoleTextArea.getIn());
    ShellMain.setOut(this.consoleTextArea.getOut());
    ShellMain.setErr(this.consoleTextArea.getErr());

    // we don't do this here as we want to separate construction from
    // the run thread
    this.args = args;

    //ShellMain.exec(args);
}

From source file:com.game.ui.views.MapEditor.java

public void generateGUI() throws IOException {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    //        setResizable(false);
    JMenuBar menubar = new JMenuBar();
    ImageIcon icon = null;/*from  www  .j  a  v  a  2  s .  com*/
    try {
        icon = GameUtils.shrinkImage("save.png", 20, 20);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JMenu file = new JMenu("File");
    JMenuItem save = new JMenuItem("Save", icon);
    save.setToolTipText("Save Map Information");
    save.setActionCommand("Save Map");
    save.addActionListener(this);
    file.add(save);
    menubar.add(file);
    setJMenuBar(menubar);
    JPanel topPanel = new JPanel();
    topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    topPanel.setLayout(new GridBagLayout());
    JLabel headerLbl = new JLabel("Legend : ");
    headerLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    JLabel lbl1 = new JLabel();
    lbl1.setPreferredSize(new Dimension(50, 20));
    lbl1.setBackground(Configuration.pathColor);
    lbl1.setOpaque(true);
    JLabel lbl2 = new JLabel("- Represents the path.");
    JLabel lbl3 = new JLabel();
    lbl3.setPreferredSize(new Dimension(50, 20));
    lbl3.setBackground(Configuration.enemyColor);
    lbl3.setOpaque(true);
    JLabel lbl4 = new JLabel("- Represents the path with monsters");
    JLabel lbl5 = new JLabel();
    lbl5.setPreferredSize(new Dimension(50, 20));
    lbl5.setBackground(Configuration.startPointColor);
    lbl5.setOpaque(true);
    JLabel lbl6 = new JLabel("- Represents the starting point in the path");
    JLabel lbl7 = new JLabel();
    lbl7.setBackground(Configuration.endPointColor);
    lbl7.setOpaque(true);
    lbl7.setPreferredSize(new Dimension(50, 20));
    JLabel lbl8 = new JLabel("- Ending point in the path");
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 2;
    topPanel.add(headerLbl, c);
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.ipadx = 5;
    c.ipady = 5;
    topPanel.add(lbl1, c);
    c.gridx = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    topPanel.add(lbl2, c);
    c.gridx = 0;
    c.gridy = 2;
    topPanel.add(lbl3, c);
    c.gridx = 1;
    topPanel.add(lbl4, c);
    c.gridx = 0;
    c.gridy = 3;
    topPanel.add(lbl5, c);
    c.gridx = 1;
    topPanel.add(lbl6, c);
    c.gridx = 0;
    c.gridy = 4;
    topPanel.add(lbl7, c);
    c.gridx = 1;
    topPanel.add(lbl8, c);
    add(topPanel, BorderLayout.NORTH);
    bottomPanel = new JPanel();
    add(bottomPanel, BorderLayout.CENTER);
    bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    //        bottomPanel.add(new JButton("kaushik"));
    pack();
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(env.getMaximumWindowBounds());
    setVisible(true);
    callDialogForUsersInput();
}

From source file:it.unibas.spicygui.controllo.provider.composition.MyPopupProviderWidgetChainComposition.java

private void createPopupMenu() {
    menu = new JPopupMenu("Popup menu");

    JMenuItem itemDeleteWidget;

    itemDeleteWidget = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.DELETE_WIDGET_COMPOSITION));
    itemDeleteWidget.setActionCommand(DELETE);
    itemDeleteWidget.addActionListener(this);
    menu.add(itemDeleteWidget);// w  w w .j  a va2  s .  c om

    itemLoadDataSource = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.LOAD_DATASOURCE_FOR_CHAIN));
    itemLoadDataSource.setActionCommand(LOAD);
    itemLoadDataSource.addActionListener(this);
    menu.add(itemLoadDataSource);
}