Example usage for javax.swing JMenuItem getAccessibleContext

List of usage examples for javax.swing JMenuItem getAccessibleContext

Introduction

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

Prototype

@BeanProperty(bound = false)
public AccessibleContext getAccessibleContext() 

Source Link

Document

Returns the AccessibleContext associated with this JMenuItem.

Usage

From source file:MainClass.java

MainClass(String title) {
    super(title);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JToolBar toolBar = new JToolBar();
    Action a = new AbstractAction("Demo") {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Action taken.");
        }/*from w ww  .  ja  va  2 s .c o m*/
    };

    JButton b = toolBar.add(a);
    b.setText("Demo Button");
    b.setToolTipText("Press me to take action.");

    JMenu mainMenu = new JMenu("Menu");
    JMenuItem mi = mainMenu.add(a);
    mi.getAccessibleContext().setAccessibleName("Menu item");

    JMenuBar mb = new JMenuBar();
    mb.add(mainMenu);
    setJMenuBar(mb);

    JPanel pane = new JPanel();
    pane.setLayout(new BorderLayout());
    pane.setPreferredSize(new Dimension(200, 100));
    pane.add(toolBar, BorderLayout.NORTH);
    setContentPane(pane);

    pack();
    setVisible(true);
}

From source file:components.MenuLookDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;//from  w  ww. j  a va  2  s  .co  m
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("images/middle.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menu.add(menuItem);

    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    menu.add(rbMenuItem);

    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    menu.add(cbMenuItem);

    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    submenu.add(menuItem);
    menu.add(submenu);

    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    return menuBar;
}

From source file:MenuLookDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;/*from ww  w . ja  va2s .  c o  m*/
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    // Create the menu bar.
    menuBar = new JMenuBar();

    // Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    // a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    // menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("images/middle.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menu.add(menuItem);

    // a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    menu.add(rbMenuItem);

    // a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    menu.add(cbMenuItem);

    // a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    submenu.add(menuItem);
    menu.add(submenu);

    // Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    return menuBar;
}

From source file:components.MenuDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;//  www . ja v  a  2  s . co m
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("images/middle.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menu.add(submenu);

    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    return menuBar;
}

From source file:MenuDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;//from  w  w w  .  j a va2  s  .co m
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("images/1.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menu.add(submenu);

    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    return menuBar;
}

From source file:components.MenuSelectionManagerDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;/*  w ww  . j  a  v a  2 s  .c om*/
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("images/middle.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menu.add(submenu);

    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    Timer timer = new Timer(ONE_SECOND, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath();
            for (int i = 0; i < path.length; i++) {
                if (path[i].getComponent() instanceof javax.swing.JMenuItem) {
                    JMenuItem mi = (JMenuItem) path[i].getComponent();
                    if ("".equals(mi.getText())) {
                        output.append("ICON-ONLY MENU ITEM > ");
                    } else {
                        output.append(mi.getText() + " > ");
                    }
                }
            }
            if (path.length > 0)
                output.append(newline);
        }
    });
    timer.start();
    return menuBar;
}

From source file:MenuSelectionManagerDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;//w  w  w  . j a v  a  2s .c om
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("1.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menu.add(submenu);

    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    Timer timer = new Timer(ONE_SECOND, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath();
            for (int i = 0; i < path.length; i++) {
                if (path[i].getComponent() instanceof javax.swing.JMenuItem) {
                    JMenuItem mi = (JMenuItem) path[i].getComponent();
                    if ("".equals(mi.getText())) {
                        output.append("ICON-ONLY MENU ITEM > ");
                    } else {
                        output.append(mi.getText() + " > ");
                    }
                }
            }
            if (path.length > 0)
                output.append(newline);
        }
    });
    timer.start();
    return menuBar;
}

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

/**
 * Cria o menu//from  ww w  .j a  va2  s .  c om
 * 
 * @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 ww.ja  va2  s . c om
            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
 * /*from ww w  .j  ava 2s .  c  o m*/
 * @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;
}