Example usage for javax.swing JMenuItem setToolTipText

List of usage examples for javax.swing JMenuItem setToolTipText

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:Submenu.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    JMenuBar menubar = new JMenuBar();
    ImageIcon iconNew = new ImageIcon("new.png");
    ImageIcon iconOpen = new ImageIcon("open.png");
    ImageIcon iconSave = new ImageIcon("save.png");
    ImageIcon iconClose = new ImageIcon("exit.png");

    JMenu file = new JMenu("File");
    JMenu imp = new JMenu("Import");

    JMenuItem fileNew = new JMenuItem("New", iconNew);
    JMenuItem fileOpen = new JMenuItem("Open", iconOpen);
    JMenuItem fileSave = new JMenuItem("Save", iconSave);
    JMenuItem fileClose = new JMenuItem("Close", iconClose);

    file.setMnemonic(KeyEvent.VK_F);
    imp.setMnemonic(KeyEvent.VK_M);

    JMenuItem newsf = new JMenuItem("Import newsfeed list...");
    JMenuItem bookm = new JMenuItem("Import bookmarks...");
    JMenuItem mail = new JMenuItem("Import mail...");

    imp.add(newsf);//from   w w  w .  j av a  2 s  .c om
    imp.add(bookm);
    imp.add(mail);

    fileNew.setMnemonic(KeyEvent.VK_N);
    fileNew.setMnemonic(KeyEvent.VK_O);
    fileSave.setMnemonic(KeyEvent.VK_S);

    fileClose.setMnemonic(KeyEvent.VK_C);
    fileClose.setToolTipText("Exit application");
    fileClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK));

    fileClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });

    file.add(fileNew);
    file.add(fileOpen);
    file.add(fileSave);
    file.addSeparator();
    file.add(imp);
    file.addSeparator();
    file.add(fileClose);

    menubar.add(file);

    f.setJMenuBar(menubar);

    f.setSize(360, 250);
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:Main.java

public static JMenuItem createMenuItem(String text, Icon icon, String toolTip, ActionListener... listeners) {
    JMenuItem result = new JMenuItem(text, icon);

    if (toolTip != null) {
        result.setToolTipText(toolTip);
    }//ww w  .j  ava2s .c  om

    for (ActionListener listener : listeners) {
        result.addActionListener(listener);
    }

    return result;
}

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   w  w w . ja  va 2 s . c om
    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:net.pandoragames.far.ui.swing.component.FileListPopupMenu.java

private void init(Localizer localizer, ComponentRepository componentRepository) {
    //   Edit/*from ww  w.jav a  2 s  . c  o  m*/
    edit = new JMenuItem(localizer.localize("label.edit"));
    edit.setToolTipText(localizer.localize("tooltip.edit"));
    edit.setMnemonic(config.getAccessKey("popup.label.edit"));
    edit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileEditor editor = new FileEditor(mainFrame, tableModel.getRow(selectedRow), config);
            editor.pack();
            editor.setVisible(true);
        }
    });
    this.add(edit);
    //   View
    JMenuItem view = new JMenuItem(viewAction);
    view.setToolTipText(localizer.localize("tooltip.view"));
    this.add(view);
    //   Preview
    JMenuItem preview = new JMenuItem(previewAction);
    preview.setToolTipText(localizer.localize("tooltip.preview"));
    this.add(preview);
    //   Info
    info = new JMenuItem(localizer.localize("label.info"));
    info.setToolTipText(localizer.localize("tooltip.info"));
    info.setMnemonic(config.getAccessKey("popup.label.info"));
    info.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            InfoView infoView = new InfoView(mainFrame, tableModel.getRow(selectedRow), config, repository);
            infoView.pack();
            infoView.setVisible(true);
        }
    });
    this.add(info);
    if (SwingConfig.getEffectiveJavaVersion() > 5 && DesktopHelper.isFileOpeningSupported()) {

        openItemsAreActive = true;
        // seperator 
        this.addSeparator();

        openFile = new JMenuItem(localizer.localize("label.open-file"));
        openFile.setToolTipText(localizer.localize("tooltip.open-file"));
        openFile.setMnemonic(config.getAccessKey("popup.label.open-file"));
        openFile.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    DesktopHelper.openFile(tableModel.getRow(selectedRow).getFile());
                } catch (IOException iox) {
                    errorSink.error(iox.getMessage());
                }
            }
        });
        this.add(openFile);
        openDir = new JMenuItem(localizer.localize("label.open-directory"));
        openDir.setToolTipText(localizer.localize("tooltip.open-directory"));
        openDir.setMnemonic(config.getAccessKey("popup.label.open-directory"));
        this.add(openDir);
        openDir.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    DesktopHelper.openFile(tableModel.getRow(selectedRow).getFile().getParentFile());
                } catch (IOException iox) {
                    errorSink.error(iox.getMessage());
                }
            }
        });
    }
    // seperator 
    this.addSeparator();
    // rename
    rename = new JMenuItem(localizer.localize("menu.rename-dialog"));
    rename.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileOperationDialog.renameDialog(selectedRow, tableModel, findForm, errorSink, config, mainFrame);
        }
    });
    this.add(rename);
    // copy
    copy = new JMenuItem(localizer.localize("menu.copy"));
    copy.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int index = selectedRow;
            int count = 1;
            if (fileTable.getSelectedRowCount() > 0) {
                index = fileTable.getSelectedRow();
                count = fileTable.getSelectedRowCount();
            }
            FileOperationDialog.copyDialog(index, count, tableModel, findForm, errorSink, config, mainFrame);
        }
    });
    this.add(copy);
    // tree copy
    treeCopy = new JMenuItem(localizer.localize("menu.treeCopy"));
    treeCopy.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int index = selectedRow;
            int count = 1;
            if (fileTable.getSelectedRowCount() > 0) {
                index = fileTable.getSelectedRow();
                count = fileTable.getSelectedRowCount();
            }
            FileOperationDialog.treeCopyDialog(index, count, tableModel, findForm, errorSink, config,
                    mainFrame);
        }
    });
    this.add(treeCopy);
    // move
    move = new JMenuItem(localizer.localize("menu.move"));
    move.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int index = selectedRow;
            int count = 1;
            if (fileTable.getSelectedRowCount() > 0) {
                index = fileTable.getSelectedRow();
                count = fileTable.getSelectedRowCount();
            }
            FileOperationDialog.moveDialog(index, count, tableModel, findForm, errorSink, config, mainFrame);
        }
    });
    this.add(move);
    // delete
    delete = new JMenuItem(localizer.localize("menu.delete"));
    delete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int index = selectedRow;
            int count = 1;
            if (fileTable.getSelectedRowCount() > 0) {
                index = fileTable.getSelectedRow();
                count = fileTable.getSelectedRowCount();
            }
            FileOperationDialog.deleteDialog(index, count, tableModel, findForm.getBaseDirectory(), errorSink,
                    config, mainFrame);
        }
    });
    this.add(delete);
}

From source file:org.sbml.bargraph.MainWindow.java

/**
 * Set up menus when running under Windows.
 *//*from   www  .  jav  a 2s. c o m*/
public void registerForEvents() {
    Log.note("Setting up the Windows menus.");

    JMenuItem fileExitItem = new JMenuItem();
    fileExitItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, shortcutKeyMask));
    fileExitItem.setMnemonic(java.awt.event.KeyEvent.VK_C);
    fileExitItem.setText("Exit");
    fileExitItem.setToolTipText("Exit application");
    fileExitItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            quit();
        }
    });

    fileMenu.addSeparator();
    fileMenu.add(fileExitItem);

    JMenu helpMenu = new JMenu();
    helpMenu.setText("Help");

    JMenuItem aboutMenuItem = new JMenuItem();
    aboutMenuItem.setText("About " + Config.APP_NAME);
    aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            about();
        }
    });

    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);
}

From source file:net.chaosserver.timelord.swingui.TimelordMenu.java

/**
 * Creates the file menu.//from w  w  w. j  a  va  2 s .  co m
 *
 * @return the new file menu
 */
protected JMenu createFileMenu() {
    JMenu fileMenu = new JMenu(resourceBundle.getString(RROOT + ".fileMenuName"));
    JMenuItem menuItem;

    fileMenu.setMnemonic(KeyEvent.VK_F);

    JMenu exportMenu = new JMenu(resourceBundle.getString(RROOT + ".file.export"));
    exportMenu.setMnemonic(KeyEvent.VK_A);

    menuItem = new JMenuItem(resourceBundle.getString(RROOT + ".file.export.jordan"), KeyEvent.VK_J);

    menuItem.setToolTipText(resourceBundle.getString(RROOT + ".file.export.jordan.tooltip"));

    menuItem.setActionCommand(ACTION_EXPORT_JORDAN);
    menuItem.addActionListener(this);
    exportMenu.add(menuItem);

    menuItem = new JMenuItem(resourceBundle.getString(RROOT + ".file.export.doug"), KeyEvent.VK_D);

    menuItem.setToolTipText("For Losers");
    menuItem.setActionCommand(ACTION_EXPORT_DOUG);
    menuItem.addActionListener(this);
    exportMenu.add(menuItem);

    exportMenu.addSeparator();
    menuItem = new JMenuItem("XML...", KeyEvent.VK_X);
    menuItem.setActionCommand(ACTION_EXPORT_XML);
    menuItem.addActionListener(this);
    exportMenu.add(menuItem);

    fileMenu.add(exportMenu);

    if (!OsUtil.isMac()) {
        fileMenu.addSeparator();
        menuItem = new JMenuItem("Exit", KeyEvent.VK_X);
        menuItem.setActionCommand(ACTION_EXIT);
        menuItem.addActionListener(this);
        fileMenu.add(menuItem);
    }

    return fileMenu;
}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * @param menu/*from   w w w.jav a 2s . c om*/
 */
private void makeRecentSubMenu(JMenu menu) {

    menu.removeAll();

    for (final Map.Entry<String, String> entry : RuntimeProperties.getRecentPackages().entrySet()) {

        JMenuItem menuItem = new JMenuItem(entry.getKey());
        menuItem.setToolTipText(entry.getValue());

        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                openNewCanvasWithPackage(new File(entry.getValue()));
            }
        });
        menu.add(menuItem);
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.corretor_eventos.PanelCorretorEventos.java

/**
 * Cria o menu//from w  w  w .  jav a  2 s  .c  o m
 * 
 * @return o menu
 */
private JMenuBar criaMenuBar() {
    menuBar = new JMenuBar();
    menuBar.setBackground(frameSilvinha.corDefault);

    JMenu menuArquivo = new JMenu(XHTML_Panel.ARQUIVO);
    menuArquivo.setMnemonic('A');
    menuArquivo.setMnemonic(KeyEvent.VK_A);

    JMenu avaliadores = new JMenu();
    MenuSilvinha menuSilvinha = new MenuSilvinha(frameSilvinha, null);
    menuSilvinha.criaMenuAvaliadores(avaliadores);
    // menuArquivo.add(avaliadores);
    // menuArquivo.add(new JSeparator());

    JMenuItem btnAbrir = new JMenuItem(XHTML_Panel.BTN_ABRIR);
    btnAbrir.addActionListener(this);
    btnAbrir.setActionCommand("Abrir");
    btnAbrir.setMnemonic('A');
    btnAbrir.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    btnAbrir.setMnemonic(KeyEvent.VK_A);
    btnAbrir.setToolTipText(XHTML_Panel.DICA_ABRIR);
    btnAbrir.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_ABRIR);
    menuArquivo.add(btnAbrir);

    JMenuItem btnAbrirUrl = new JMenuItem(XHTML_Panel.BTN_ABRIR_URL);
    btnAbrirUrl.addActionListener(this);
    btnAbrirUrl.setActionCommand("AbrirURL");
    btnAbrirUrl.setMnemonic('U');
    btnAbrirUrl.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, ActionEvent.CTRL_MASK));
    btnAbrirUrl.setMnemonic(KeyEvent.VK_U);
    btnAbrirUrl.setToolTipText(XHTML_Panel.DICA_ABRIR);
    btnAbrirUrl.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_ABRIR);
    menuArquivo.add(btnAbrirUrl);

    miBtnSalvar.addActionListener(this);
    miBtnSalvar.setActionCommand("Salvar");
    miBtnSalvar.setMnemonic('S');
    miBtnSalvar.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    miBtnSalvar.setMnemonic(KeyEvent.VK_S);
    miBtnSalvar.getAccessibleContext().setAccessibleDescription(XHTML_Panel.BTN_SALVAR);
    miBtnSalvar.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_SALVAR);
    menuArquivo.add(miBtnSalvar);

    JMenuItem btnSalvarAs = new JMenuItem(XHTML_Panel.BTN_SALVAR_COMO);
    btnSalvarAs.addActionListener(this);
    btnSalvarAs.setActionCommand("SaveAs");
    btnSalvarAs.setMnemonic('c');
    btnSalvarAs.setMnemonic(KeyEvent.VK_C);
    // btnSalvarAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
    // ActionEvent.CTRL_MASK));
    btnSalvarAs.setToolTipText(XHTML_Panel.DICA_SALVAR_COMO);
    btnSalvarAs.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_SALVAR_COMO);
    menuArquivo.add(btnSalvarAs);

    JMenuItem btnFechar = new JMenuItem(XHTML_Panel.SAIR);
    btnFechar.addActionListener(this);
    btnFechar.setActionCommand("Sair");
    btnFechar.setMnemonic('a');
    btnFechar.setMnemonic(KeyEvent.VK_A);
    btnFechar.setToolTipText(XHTML_Panel.DICA_SAIR);
    btnFechar.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_SAIR);
    menuArquivo.add(btnFechar);

    menuBar.add(menuArquivo);

    JMenu menuEditar = new JMenu(XHTML_Panel.EDITAR);
    menuBar.add(criaMenuEditar(menuEditar));

    menuBar.add(avaliadores);
    JMenu menuSimuladores = new JMenu();
    menuSilvinha.criaMenuSimuladores(menuSimuladores);
    menuBar.add(menuSimuladores);

    JMenu mnFerramenta = new JMenu();
    menuSilvinha.criaMenuFerramentas(mnFerramenta);
    menuBar.add(mnFerramenta);

    JMenu menuAjuda = new JMenu(XHTML_Panel.AJUDA);
    menuSilvinha.criaMenuAjuda(menuAjuda);
    menuBar.add(menuAjuda);

    return menuBar;
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.navegacao_cego.PainelSimuladorNavegacao.java

private JMenuBar criaMenuBar() {
    menuBar = new JMenuBar();

    menuBar.setBackground(parentFrame.corDefault);

    JMenu menuArquivo = new JMenu(GERAL.ARQUIVO);
    menuArquivo.setMnemonic('A');
    menuArquivo.setMnemonic(KeyEvent.VK_A);
    menuArquivo.setBackground(parentFrame.corDefault);

    JMenu avaliadores = new JMenu();
    MenuSilvinha menuSilvinha = new MenuSilvinha(parentFrame, null);
    menuSilvinha.criaMenuAvaliadores(avaliadores);
    // menuArquivo.add(avaliadores);
    // menuArquivo.add(new JSeparator());

    JMenuItem btnAbrir = new JMenuItem(GERAL.BTN_ABRIR);
    btnAbrir.addActionListener(this);
    btnAbrir.setActionCommand("Abrir");
    btnAbrir.setMnemonic('A');
    btnAbrir.setAccelerator(/*from w w  w  .j av  a 2  s. co m*/
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    btnAbrir.setMnemonic(KeyEvent.VK_A);
    btnAbrir.setToolTipText(TradSimuladorNavegacao.DICA_ABRE_E_AVALIA);
    btnAbrir.getAccessibleContext().setAccessibleDescription(TradSimuladorNavegacao.DICA_ABRE_E_AVALIA);
    menuArquivo.add(btnAbrir);

    JMenuItem btnAbrirUrl = new JMenuItem(XHTML_Panel.BTN_ABRIR_URL);
    btnAbrirUrl.addActionListener(this);
    btnAbrirUrl.setActionCommand("AbrirURL");
    btnAbrirUrl.setMnemonic('U');
    btnAbrirUrl.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, ActionEvent.CTRL_MASK));
    btnAbrirUrl.setMnemonic(KeyEvent.VK_U);
    btnAbrirUrl.setToolTipText(XHTML_Panel.DICA_ABRIR);
    btnAbrirUrl.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_ABRIR);
    menuArquivo.add(btnAbrirUrl);

    btnSalvar = new JMenuItem(GERAL.BTN_SALVAR);
    btnSalvar.addActionListener(this);
    btnSalvar.setActionCommand("Salvar");
    btnSalvar.setMnemonic('S');
    btnSalvar.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    btnSalvar.setMnemonic(KeyEvent.VK_S);
    btnSalvar.getAccessibleContext().setAccessibleDescription(TradSimuladorNavegacao.DICA_GRAVA_E_REAVALIA);
    // menuArquivo.add(btnSalvar);

    JMenuItem btnSalvarAs = new JMenuItem(GERAL.BTN_SALVAR_COMO);
    btnSalvarAs.addActionListener(this);
    btnSalvarAs.setActionCommand("SaveAs");
    btnSalvarAs.setMnemonic('c');
    btnSalvarAs.setMnemonic(KeyEvent.VK_C);
    // btnSalvarAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
    // ActionEvent.CTRL_MASK));
    btnSalvarAs.setToolTipText(GERAL.DICA_SALVAR_COMO);
    btnSalvarAs.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_COMO);
    // menuArquivo.add(btnSalvarAs);

    menuArquivo.add(new JSeparator());

    JMenuItem btnFechar = new JMenuItem(GERAL.SAIR);
    //btnFechar.addActionListener(this);
    btnFechar.setActionCommand("Sair");
    //btnFechar.setMnemonic(KeyEvent.VK_X);
    btnFechar.setToolTipText(GERAL.DICA_SAIR);
    //btnFechar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SAIR);
    menuArquivo.add(btnFechar);
    btnFechar.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
    btnFechar.setMnemonic('X');
    btnFechar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });

    menuBar.add(menuArquivo);

    menuBar.add(this.criaMenuEditar());

    menuBar.add(avaliadores);

    JMenu menuSimuladores = new JMenu();
    menuSilvinha.criaMenuSimuladores(menuSimuladores);
    menuBar.add(menuSimuladores);

    JMenu mnFerramenta = new JMenu();
    menuSilvinha.criaMenuFerramentas(mnFerramenta);
    menuBar.add(mnFerramenta);

    JMenu menuAjuda = new JMenu(GERAL.AJUDA);
    menuSilvinha.criaMenuAjuda(menuAjuda);
    menuBar.add(menuAjuda);

    return menuBar;
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.corretor_eventos.PanelCorretorEventos.java

/**
 * Recria o menu editar do Frame Principal
 * /*  w  w  w  .  ja va2  s.  c om*/
 * @param menu
 * @return
 */
private JMenu criaMenuEditar(JMenu menu) {
    menu.removeAll();
    menu.setMnemonic('E');
    menu.setMnemonic(KeyEvent.VK_E);

    menu.add(new JMenuItemTeclaAtalho(textAreaSourceCode));

    menu.add(new JSeparator());

    JMenuItem btnContraste = new JMenuItem(XHTML_Panel.ALTERAR_CONTRASTE);
    btnContraste.addActionListener(this);
    btnContraste.setActionCommand("Contraste");
    // btnAumenta.setMnemonic('F');
    // btnAumenta.setMnemonic(KeyEvent.VK_F);
    // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD,
    // ActionEvent.CTRL_MASK));
    btnContraste.setToolTipText(XHTML_Panel.DICA_CONTRASTE);
    btnContraste.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_CONTRASTE);
    menu.add(btnContraste);

    JMenuItem btnAumenta = new JMenuItem(XHTML_Panel.AUMENTA_FONTE);
    btnAumenta.addActionListener(this);
    btnAumenta.setActionCommand("AumentaFonte");
    // btnAumenta.setMnemonic('F');
    // btnAumenta.setMnemonic(KeyEvent.VK_F);
    btnAumenta.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK));
    btnAumenta.setToolTipText(XHTML_Panel.DICA_AUMENTA_FONTE);
    btnAumenta.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_AUMENTA_FONTE);
    menu.add(btnAumenta);

    JMenuItem btnDiminui = new JMenuItem(XHTML_Panel.DIMINUI_FONTE);
    btnDiminui.addActionListener(this);
    btnDiminui.setActionCommand("DiminuiFonte");
    // btnDiminui.setMnemonic('F');
    // btnDiminui.setMnemonic(KeyEvent.VK_F);
    btnDiminui.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK));
    btnDiminui.setToolTipText(XHTML_Panel.DICA_DIMINUI_FONTE);
    btnDiminui.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_DIMINUI_FONTE);
    menu.add(btnDiminui);

    menu.add(new JSeparator());

    JMenuItem btnProcurar = new JMenuItem(XHTML_Panel.PROCURAR);
    btnProcurar.addActionListener(this);
    btnProcurar.setActionCommand("Procurar");
    btnProcurar.setMnemonic('P');
    btnProcurar.setMnemonic(KeyEvent.VK_P);
    btnProcurar.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK));
    btnProcurar.setToolTipText(XHTML_Panel.DICA_PROCURAR);
    btnProcurar.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_PROCURAR);
    menu.add(btnProcurar);

    JMenuItem btnSelecionarTudo = new JMenuItem(XHTML_Panel.SELECIONAR_TUDO);
    btnSelecionarTudo.addActionListener(this);
    btnSelecionarTudo.setActionCommand("SelecionarTudo");
    btnSelecionarTudo.setMnemonic('T');
    btnSelecionarTudo.setMnemonic(KeyEvent.VK_T);
    btnSelecionarTudo.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK));
    btnSelecionarTudo.setToolTipText(XHTML_Panel.DICA_SELECIONAR_TUDO);
    btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_SELECIONAR_TUDO);
    menu.add(btnSelecionarTudo);

    JMenuItem btnDesfazer = new JMenuItem(XHTML_Panel.DESFAZER);
    btnDesfazer.addActionListener(this);
    btnDesfazer.setActionCommand("Desfazer");
    btnDesfazer.setMnemonic('z');
    btnDesfazer.setMnemonic(KeyEvent.VK_Z);
    btnDesfazer.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
    btnDesfazer.setToolTipText(XHTML_Panel.DICA_DESFAZER);
    btnDesfazer.getAccessibleContext().setAccessibleDescription(XHTML_Panel.DICA_DESFAZER);

    menu.add(btnDesfazer);
    return menu;
}