Example usage for javax.swing JMenu setMnemonic

List of usage examples for javax.swing JMenu setMnemonic

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, description = "the keyboard character mnemonic")
public void setMnemonic(int mnemonic) 

Source Link

Document

Sets the keyboard mnemonic on the current model.

Usage

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.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  .  c  o m
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    btnAbrir.setMnemonic(KeyEvent.VK_A);
    btnAbrir.setToolTipText(GERAL.DICA_ABRIR);
    btnAbrir.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ABRIR);
    menuArquivo.add(btnAbrir);

    JMenuItem btnAbrirUrl = new JMenuItem(br.org.acessobrasil.silvinha2.mli.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(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR);
    btnAbrirUrl.getAccessibleContext()
            .setAccessibleDescription(br.org.acessobrasil.silvinha2.mli.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(GERAL.DICA_SALVAR);
    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('a');
    btnFechar.setMnemonic(KeyEvent.VK_A);
    btnFechar.setToolTipText(GERAL.DICA_SAIR);
    btnFechar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SAIR);
    menuArquivo.add(btnFechar);

    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(XHTML_Panel.AJUDA);
    menuSilvinha.criaMenuAjuda(menuAjuda);
    menuBar.add(menuAjuda);

    return menuBar;
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.java

/**
 * Cria o menu editar do Frame Principal
 * //from   www .j a v a2s.com
 * @param menu
 */
private JMenu criaMenuEditar() {
    JMenu menu = new JMenu(GERAL.EDITAR);
    menu.setBackground(parentFrame.corDefault);
    menu.setMnemonic('E');
    menu.setMnemonic(KeyEvent.VK_E);

    JMenuItem btnContraste = new JMenuItem(GERAL.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(GERAL.DICA_CONTRASTE);
    btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.DICA_CONTRASTE);
    menu.add(btnContraste);

    JMenuItem btnAumenta = new JMenuItem(GERAL.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(GERAL.DICA_AUMENTA_FONTE);
    btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE);
    menu.add(btnAumenta);

    JMenuItem btnDiminui = new JMenuItem(GERAL.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(GERAL.DICA_DIMINUI_FONTE);
    btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE);
    menu.add(btnDiminui);

    menu.add(new JSeparator());

    JMenuItem btnProcurar = new JMenuItem(GERAL.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(GERAL.DICA_PROCURAR);
    btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR);
    menu.add(btnProcurar);

    JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.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(GERAL.DICA_SELECIONAR_TODO_CSS);
    btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TODO_CSS);
    menu.add(btnSelecionarTudo);

    JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER);
    btnDesfazer.addActionListener(this);
    btnDesfazer.setActionCommand("Desfazer");
    btnDesfazer.setMnemonic('z');
    btnDesfazer.setMnemonic(KeyEvent.VK_Z);
    btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER);
    btnDesfazer.setAccelerator(
            javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
    menu.add(btnDesfazer);
    menu.setEnabled(true);
    return menu;
}

From source file:es.darkhogg.hazelnutt.EditorFrame.java

private void initializeGui() {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    setBounds(100, 100, 640, 480);/*  ww w  . j  a va2 s.co  m*/

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            actionExit();
        }
    });

    fileChooser = new JFileChooser();
    //fileChooser.setFileFilter( hlfFileFilter );

    hlfFileChooser = new JFileChooser();
    hlfFileChooser.setFileFilter(hlfFileFilter);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    menuBar.add(mnFile);

    menuLoadRom = new JMenuItem("Load ROM...");
    menuLoadRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
    menuLoadRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionOpenRom(null);
        }
    });
    menuLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png")));
    menuLoadRom.setMnemonic('O');
    mnFile.add(menuLoadRom);

    menuSaveRom = new JMenuItem("Save ROM");
    menuSaveRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveRom();
        }
    });
    menuSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png")));
    menuSaveRom.setMnemonic('S');
    menuSaveRom.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
    mnFile.add(menuSaveRom);

    menuSaveRomAs = new JMenuItem("Save ROM As...");
    menuSaveRomAs.setMnemonic('a');
    menuSaveRomAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));
    menuSaveRomAs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveRomAs();
        }
    });
    menuSaveRomAs
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_as.png")));
    mnFile.add(menuSaveRomAs);

    mnFile.addSeparator();

    menuLoadLevel = new JMenuItem("Load Level...");
    menuLoadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0));
    menuLoadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionLoadLevel();
        }
    });
    menuLoadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png")));
    menuLoadLevel.setMnemonic('L');
    mnFile.add(menuLoadLevel);

    menuReloadLevel = new JMenuItem("Reload Level");
    menuReloadLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0));
    menuReloadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionReloadLevel();
        }
    });
    menuReloadLevel.setMnemonic('R');
    menuReloadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png")));
    mnFile.add(menuReloadLevel);

    menuSaveLevel = new JMenuItem("Save Level");
    menuSaveLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0));
    menuSaveLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveLevel();
        }
    });
    menuSaveLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png")));
    menuSaveLevel.setMnemonic('v');

    mnFile.add(menuSaveLevel);

    //*
    mnFile.addSeparator();

    menuImportLevel = new JMenuItem("Import Level...");
    menuImportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    menuImportLevel.setMnemonic('i');
    menuImportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionImportLevel();
        }
    });
    menuImportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png")));
    mnFile.add(menuImportLevel);

    menuExportLevel = new JMenuItem("Export Level...");
    menuExportLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    menuExportLevel.setMnemonic('e');
    menuExportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionExportLevel();
        }
    });
    menuExportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png")));
    mnFile.add(menuExportLevel);
    //*/

    mnFile.addSeparator();

    menuExit = new JMenuItem("Exit");
    menuExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
    menuExit.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_exit.png")));
    menuExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            actionExit();
        }
    });

    menuRecentFiles = new JMenu("Recent Files...");
    mnFile.add(menuRecentFiles);

    mnFile.addSeparator();
    menuExit.setMnemonic('X');
    mnFile.add(menuExit);

    JMenu mnEdit = new JMenu("Edit");
    mnEdit.setMnemonic('E');
    menuBar.add(mnEdit);

    menuViewSpawn = new JCheckBoxMenuItem("View Spawn Point");
    menuViewSpawn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0));
    menuViewSpawn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });

    menuClearLevel = new JMenuItem("Clear Level");
    menuClearLevel.setMnemonic('c');
    menuClearLevel.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    menuClearLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionClearLevel();
        }
    });
    menuClearLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png")));
    mnEdit.add(menuClearLevel);

    mnEdit.addSeparator();

    menuViewSpawn
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png")));
    menuViewSpawn.setMnemonic('S');
    menuViewSpawn.setSelected(true);
    mnEdit.add(menuViewSpawn);

    menuViewItems = new JCheckBoxMenuItem("View Items");
    menuViewItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0));
    menuViewItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewItems.setSelected(true);
    menuViewItems
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png")));
    menuViewItems.setMnemonic('I');
    mnEdit.add(menuViewItems);

    menuViewDoorItems = new JCheckBoxMenuItem("View Door Items");
    menuViewDoorItems.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0));
    menuViewDoorItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewDoorItems.setSelected(true);
    menuViewDoorItems.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png")));
    menuViewDoorItems.setMnemonic('D');
    mnEdit.add(menuViewDoorItems);

    menuViewEnemies = new JCheckBoxMenuItem("View Enemies");
    menuViewEnemies.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0));
    menuViewEnemies.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewEnemies.setSelected(true);
    menuViewEnemies
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png")));
    menuViewEnemies.setMnemonic('E');
    mnEdit.add(menuViewEnemies);

    menuViewTypes = new JCheckBoxMenuItem("View Combo Types");
    menuViewTypes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0));
    menuViewTypes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(false);
        }
    });
    menuViewTypes.setSelected(true);
    menuViewTypes.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png")));
    menuViewTypes.setMnemonic('C');
    mnEdit.add(menuViewTypes);

    mnEdit.addSeparator();

    scaleMenuItem = new JCheckBoxMenuItem("Scale Level Display");
    scaleMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, 0));
    scaleMenuItem.setMnemonic('l');
    scaleMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionScale(false);
        }
    });
    scaleMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png")));
    mnEdit.add(scaleMenuItem);

    gridMenuItem = new JCheckBoxMenuItem("Display grid");
    gridMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, 0));
    gridMenuItem.setMnemonic('G');
    gridMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionGrid(false);
        }
    });
    gridMenuItem.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png")));
    mnEdit.add(gridMenuItem);

    //mnEdit.addSeparator();

    mntmPreferences = new JMenuItem("Preferences...");
    mntmPreferences.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionPreferences();
        }
    });
    mntmPreferences.setMnemonic('P');
    mntmPreferences.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_preferences.png")));
    //mnEdit.add(mntmPreferences);

    mnHelp = new JMenu("Help");
    mnHelp.setMnemonic('H');
    menuBar.add(mnHelp);

    mntmCheckUpdates = new JMenuItem("Check for Updates...");
    mntmCheckUpdates.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK));
    mntmCheckUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionCheckUpdates();
        }
    });
    mntmCheckUpdates.setMnemonic('c');
    mntmCheckUpdates
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_update.png")));
    mnHelp.add(mntmCheckUpdates);

    mntmAbout = new JMenuItem("Readme...");
    mntmAbout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    mntmAbout.setMnemonic('r');
    mntmAbout.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/about.png")));
    mntmAbout.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionAbout();
        }
    });
    mnHelp.addSeparator();
    mnHelp.add(mntmAbout);

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    contentPane.add(toolBar, BorderLayout.NORTH);

    barLoadRom = new JButton("");
    barLoadRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionOpenRom(null);
        }
    });
    barLoadRom.setToolTipText("Open");
    barLoadRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_open.png")));
    toolBar.add(barLoadRom);

    barSaveRom = new JButton("");
    barSaveRom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveRom();
        }
    });
    barSaveRom.setToolTipText("Save");
    barSaveRom.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save.png")));
    toolBar.add(barSaveRom);

    toolBar.addSeparator();

    barImportLevel = new JButton("");
    barImportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionImportLevel();
        }
    });
    barImportLevel.setToolTipText("Import Level");
    barImportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_import.png")));
    toolBar.add(barImportLevel);

    barExportLevel = new JButton("");
    barExportLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionExportLevel();
        }
    });
    barExportLevel.setToolTipText("Export Level");
    barExportLevel
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_export.png")));
    toolBar.add(barExportLevel);

    toolBar.addSeparator();

    barLoadLevel = new JButton("");
    barLoadLevel.setToolTipText("Load Level");
    barLoadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionLoadLevel();
        }
    });
    barLoadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_load_level.png")));
    toolBar.add(barLoadLevel);

    barReloadLevel = new JButton("");
    barReloadLevel.setToolTipText("Reload Current Level");
    barReloadLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionReloadLevel();
        }
    });
    barReloadLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_reload_level.png")));
    toolBar.add(barReloadLevel);

    barSaveLevel = new JButton("");
    barSaveLevel.setToolTipText("Save Level");
    barSaveLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionSaveLevel();
        }
    });
    barSaveLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_save_level.png")));
    toolBar.add(barSaveLevel);

    toolBar.addSeparator();

    barViewItems = new JToggleButton("");
    barViewItems.setToolTipText("Toggle View Items");
    barViewItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });

    barViewSpawn = new JToggleButton("");
    barViewSpawn.setToolTipText("Toggle View Spawn");
    barViewSpawn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });

    barClearLevel = new JButton("");
    barClearLevel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionClearLevel();
        }
    });
    barClearLevel.setToolTipText("Clear Level");
    barClearLevel.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_clear_level.png")));
    toolBar.add(barClearLevel);

    toolBar.addSeparator();

    barViewSpawn.setSelected(true);
    barViewSpawn.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_spawn.png")));
    toolBar.add(barViewSpawn);
    barViewItems.setSelected(true);
    barViewItems.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_items.png")));
    toolBar.add(barViewItems);

    barViewDoorItems = new JToggleButton("");
    barViewDoorItems.setToolTipText("Toggle View Door Items");
    barViewDoorItems.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });
    barViewDoorItems.setSelected(true);
    barViewDoorItems.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_door_items.png")));
    toolBar.add(barViewDoorItems);

    barViewEnemies = new JToggleButton("");
    barViewEnemies.setToolTipText("toggle View Enemies");
    barViewEnemies.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });
    barViewEnemies.setSelected(true);
    barViewEnemies
            .setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_enemies.png")));
    toolBar.add(barViewEnemies);

    barViewTypes = new JToggleButton("");
    barViewTypes.setToolTipText("Toggle view Combo Help");
    barViewTypes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionToggle(true);
        }
    });
    barViewTypes.setSelected(true);
    barViewTypes.setIcon(
            new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_combo_infos.png")));
    toolBar.add(barViewTypes);

    barViewSpawn.setSelected(config.getBoolean("Hazelnutt.gui.viewSpawn", true));
    barViewItems.setSelected(config.getBoolean("Hazelnutt.gui.viewItems", true));
    barViewDoorItems.setSelected(config.getBoolean("Hazelnutt.gui.viewDoorItems", true));
    barViewEnemies.setSelected(config.getBoolean("Hazelnutt.gui.viewEnemies", true));
    barViewTypes.setSelected(config.getBoolean("Hazelnutt.gui.viewHelp", true));

    panel = new JPanel();
    contentPane.add(panel, BorderLayout.EAST);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    selectorPanel = new SelectorPanel();
    selectorPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"),
            "Combo & Entity Selector", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    panel.add(selectorPanel);

    propertiesPanel = new PropertiesPanel(null);
    propertiesPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level Properties",
            TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    panel.add(propertiesPanel);

    toolBar.addSeparator();

    scaleButton = new JToggleButton("");
    scaleButton.setToolTipText("Toggle Scale Display");
    scaleButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionScale(true);
        }
    });
    scaleButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_x2.png")));
    toolBar.add(scaleButton);

    scaleButton.setSelected(config.getBoolean("Hazelnutt.gui.scaled", false));

    gridButton = new JToggleButton("");
    gridButton.setToolTipText("Display Grid");
    gridButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            actionGrid(true);
        }
    });
    gridButton.setIcon(new ImageIcon(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/icon_grid.png")));
    toolBar.add(gridButton);

    gridButton.setSelected(config.getBoolean("Hazelnutt.gui.grid", false));

    Component horizontalGlue = Box.createHorizontalGlue();
    toolBar.add(horizontalGlue);

    Component verticalGlue = Box.createVerticalGlue();
    panel.add(verticalGlue);

    levelWrapper = new JPanel();
    levelWrapper.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Level",
            TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 70, 213)));
    contentPane.add(levelWrapper, BorderLayout.CENTER);
    levelWrapper.setLayout(new BorderLayout(0, 0));

    scrollPane = new JScrollPane();
    scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
    levelWrapper.add(scrollPane);

    levelDisplay = new LevelDisplay();
    levelDisplay.addEditListener(new EditListener() {
        @Override
        public void leftPressed(int x, int y) {
            SelectionType st = selectorPanel.getSelectionType();
            Object so = selectorPanel.getSelectedObject();

            if (st == SelectionType.COMBO) {
                paintComboAt(x, y, ((Byte) so).byteValue());
            } else if (st == SelectionType.SPAWN) {
                selectedLevel.getRomLevel().setSpawn(new IntVector(x, y));

                levelHasChanged = true;
            } else if (st == SelectionType.ITEM) {
                Item ent = new Item((ItemType) so, x, y);
                EntityCollection<Item> ents = selectedLevel.getRomLevel().getItems();
                for (Iterator<Item> it = ents.iterator(); it.hasNext();) {
                    Item item = it.next();
                    if (item.getX() == x && item.getY() == y) {
                        it.remove();
                    }
                }
                if (ents.size() <= ents.maxSize()) {
                    ents.add(ent);
                    levelHasChanged = true;
                }
            } else if (st == SelectionType.DOOR_ITEM) {
                Item ent = new Item((ItemType) so, x, y);
                EntityCollection<Item> ents = selectedLevel.getRomLevel().getDoorItems();
                for (Iterator<Item> it = ents.iterator(); it.hasNext();) {
                    Item item = it.next();
                    if (item.getX() == x && item.getY() == y) {
                        it.remove();
                    }
                }
                if (ents.size() <= ents.maxSize()) {
                    ents.add(ent);
                    levelHasChanged = true;
                }
            } else if (st == SelectionType.ENEMY) {
                Enemy ent = new Enemy((EnemyType) so, x, y);
                EntityCollection<Enemy> ents = selectedLevel.getRomLevel().getEnemies();
                for (Iterator<Enemy> it = ents.iterator(); it.hasNext();) {
                    Enemy enem = it.next();
                    if (enem.getX() == x && enem.getY() == y) {
                        it.remove();
                    }
                }
                if (ents.size() <= ents.maxSize()) {
                    ents.add(ent);
                    levelHasChanged = true;
                }
            }

            updateTitle();
            levelDisplay.repaint();
            levelHasChanged = true;
        }

        @Override
        public void centerPressed(int x, int y) {
            selectorPanel.forceComboSelection(selectedLevel.getRomLevel().getData()[x][y]);
        }

        @Override
        public void rightPressed(int x, int y) {
            deleteVisibleEntitiesAt(x, y);
        }

        @Override
        public void leftDragged(int x, int y) {
            if (selectorPanel.getSelectionType() == SelectionType.COMBO) {
                paintComboAt(x, y, ((Byte) selectorPanel.getSelectedObject()).byteValue());
            }
        }

        @Override
        public void centerDragged(int x, int y) {
            // Nothing to de here
        }

        @Override
        public void rightDragged(int x, int y) {
            deleteVisibleEntitiesAt(x, y);
        }

        // Utility methods
        /*private void selectComboAt ( int x, int y ) {
                   
        }/**/
        private void paintComboAt(int x, int y, byte value) {
            selectedLevel.getRomLevel().getData()[x][y] = value;
            levelHasChanged = true;

            updateTitle();
            levelDisplay.repaint();
        }

        private void deleteVisibleEntitiesAt(int x, int y) {
            Collection<Item> items = selectedLevel.getRomLevel().getItems();
            Collection<Item> doorItems = selectedLevel.getRomLevel().getDoorItems();
            Collection<Enemy> enemies = selectedLevel.getRomLevel().getEnemies();

            if (barViewItems.isSelected()) {
                for (Iterator<Item> it = items.iterator(); it.hasNext();) {
                    Item item = it.next();
                    if (item.getX() == x && item.getY() == y) {
                        it.remove();
                        levelHasChanged = true;
                    }
                }
            }

            if (barViewDoorItems.isSelected()) {
                for (Iterator<Item> it = doorItems.iterator(); it.hasNext();) {
                    Item doorItem = it.next();
                    if (doorItem.getX() == x && doorItem.getY() == y) {
                        it.remove();
                        levelHasChanged = true;
                    }
                }
            }

            if (barViewEnemies.isSelected()) {
                for (Iterator<Enemy> it = enemies.iterator(); it.hasNext();) {
                    Enemy enem = it.next();
                    if (enem.getX() == x && enem.getY() == y) {
                        it.remove();
                        levelHasChanged = true;
                    }
                }
            }

            updateTitle();
            levelDisplay.repaint();
        }
    });
    scrollPane.setViewportView(levelDisplay);

    updateTitle();
    actionToggle(true);
    actionScale(true);
    actionGrid(true);
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(EditorFrame.class.getResource("/es/darkhogg/hazelnutt/witch_hazel_big.png")));
    setRomFeaturesEnabled(false);
    setLevelFeaturesEnabled(false);

    if (config.getBoolean("Hazelnutt.gui.maximum", false)) {
        setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
    } else {
        int x = config.getInt("Hazelnutt.gui.location.x", Integer.MIN_VALUE);
        int y = config.getInt("Hazelnutt.gui.location.y", Integer.MIN_VALUE);
        int w = config.getInt("Hazelnutt.gui.size.width", Integer.MIN_VALUE);
        int h = config.getInt("Hazelnutt.gui.size.height", Integer.MIN_VALUE);

        if (x == Integer.MIN_VALUE || x == Integer.MIN_VALUE || w == Integer.MIN_VALUE
                || h == Integer.MIN_VALUE) {
            setLocationRelativeTo(null);
        } else {
            setLocation(x, y);
            setSize(w, h);
        }
    }

    propertiesPanel.addApplyListener(new PropertiesPanel.ApplyListener() {
        @Override
        public void apply() {
            levelHasChanged = true;
            updateTitle();
            updateDisplay();
        }
    });

    if (config.containsKey("Hazelnutt.gui.lastDirectory")) {
        File lastDir = new File(config.getString("Hazelnutt.gui.lastDirectory"));
        if (lastDir.exists() && lastDir.isDirectory()) {
            //logger.debug( "Resetting the last directory: '" + lastDir + "'" );
            fileChooser.setCurrentDirectory(lastDir);
        }
    }

    // Configure the PgUp and PgDn shortcuts
    InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PgUp");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PgDn");
    ActionMap am = contentPane.getActionMap();
    am.put("PgUp", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            actionLevelUp();
        }
    });
    am.put("PgDn", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            actionLevelDown();
        }
    });

    // Get the recent files
    recentFiles = new LinkedList<String>(Arrays.asList(config.getStringArray("Hazelnutt.gui.recentFiles")));
    updateRecentFiles();

}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

private JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();
    JMenuItem mItem = null;//w  w  w  .j  av  a2s . c  o  m
    String urlString;
    URL url;

    //============================================================================================
    // File Menu
    //============================================================================================
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    menuBar.add(fileMenu);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconNew = new ImageIcon(url, "New");
    mItem = new JMenuItem(new NewTextFileAction("New", iconNew));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconOpen = new ImageIcon(url, "Open");
    mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A)));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSave = new ImageIcon(url, "Save");
    mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S)));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSaveAs = new ImageIcon(url, "Save As");
    mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconClose = new ImageIcon(url, "Close All Tabs");
    mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C)));
    fileMenu.add(mItem);

    fileMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPrint = new ImageIcon(url, "Print");
    mItem = new JMenuItem(new PrintAction("Print...", iconPrint));
    fileMenu.add(mItem);

    fileMenu.addSeparator();

    //      exit menu item
    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconExit = new ImageIcon(url, "Exit");
    mItem = new JMenuItem(new ExitAction("Exit", iconExit));
    fileMenu.add(mItem);

    //============================================================================================
    // Edit Menu
    //============================================================================================
    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic(KeyEvent.VK_E);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCut = new ImageIcon(url, "Cut");
    mItem = new JMenuItem(new DefaultEditorKit.CutAction());
    mItem.setText("Cut");
    mItem.setIcon(iconCut);
    mItem.setMnemonic(KeyEvent.VK_X);
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCopy = new ImageIcon(url, "Copy");
    mItem = new JMenuItem(new DefaultEditorKit.CopyAction());
    mItem.setText("Copy");
    mItem.setIcon(iconCopy);
    mItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPaste = new ImageIcon(url, "Paste");
    mItem = new JMenuItem(new DefaultEditorKit.PasteAction());
    mItem.setText("Paste");
    mItem.setIcon(iconPaste);
    mItem.setMnemonic(KeyEvent.VK_V);
    editMenu.add(mItem);

    editMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconUndo = new ImageIcon(url, "Undo");
    mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z)));
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconRedo = new ImageIcon(url, "Redo");
    mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y)));
    editMenu.add(mItem);

    editMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconView = new ImageIcon(url, "Preferences");
    mItem = new JMenuItem("Preferences");
    mItem.setIcon(iconView);
    mItem.setToolTipText("Edit jMetrik preferences");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JmetrikPreferencesManager prefs = new JmetrikPreferencesManager();
            prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener());
            prefs.addPropertyChangeListener(statusBar.getStatusListener());
            JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs);
            //                propDialog.loadPreferences();
            propDialog.setVisible(true);
        }
    });
    editMenu.setMnemonic('e');
    editMenu.add(mItem);

    menuBar.add(editMenu);

    //============================================================================================
    // Log Menu
    //============================================================================================
    JMenu logMenu = new JMenu("Log");

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconLog = new ImageIcon(url, "View Log");
    mItem = new JMenuItem(new ViewLogAction("View Log", iconLog));
    logMenu.setMnemonic('l');
    logMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCommand = new ImageIcon(url, "Script Log");
    mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand));
    logMenu.setMnemonic('c');
    logMenu.add(mItem);

    menuBar.add(logMenu);

    //============================================================================================
    // Manage Menu
    //============================================================================================
    JMenu manageMenu = new JMenu("Manage");
    manageMenu.setMnemonic('m');

    mItem = new JMenuItem("New Database...");//create db
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this);
            newDatabaseDialog.setVisible(true);
            if (newDatabaseDialog.canRun()) {
                if (workspace == null) {
                    //                        workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable);
                    workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable);
                    workspace.addPropertyChangeListener(statusBar.getStatusListener());
                    workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener());
                }
                workspace.runProcess(newDatabaseDialog.getCommand());
                //                    workspace.createDatabase(newDatabaseDialog.getCommand());
            }
        }
    });
    manageMenu.add(mItem);

    mItem = new JMenuItem("Open Database...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open");
            JList l = openDbDialog.getDatabaseList();
            workspace.setDatabaseListModel(l);
            openDbDialog.setVisible(true);
            if (openDbDialog.canRun()) {
                openWorkspace(openDbDialog.getDatabaseName());
            }
        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDelete = new ImageIcon(url, "Delete");
    mItem = new JMenuItem("Delete Database...");
    mItem.setIcon(iconDelete);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete");
            JList l = selectDialog.getDatabaseList();
            workspace.setDatabaseListModel(l);
            selectDialog.setVisible(true);
            if (selectDialog.canRun()) {
                int answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                        "Do you want to delete " + selectDialog.getDatabaseName()
                                + " and all of its contents? \n"
                                + "All data will be permanently deleted. You cannot undo this action.",
                        "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);

                if (answer == JOptionPane.YES_OPTION) {
                    DatabaseCommand command = new DatabaseCommand();
                    DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName());
                    command.getFreeOption("name").add(dbName.getName());
                    command.getSelectOneOption("action").setSelected("delete-db");

                    DatabaseName currentDb = workspace.getDatabaseName();
                    if (currentDb.getName().equals(dbName.getName())) {
                        JOptionPane.showMessageDialog(Jmetrik.this,
                                "You cannot delete the current database.\n"
                                        + "Close the database before attempting to delete it.",
                                "Database Delete Error", JOptionPane.WARNING_MESSAGE);
                    } else {
                        workspace.runProcess(command);
                    }

                }

            }
        }
    });
    manageMenu.add(mItem);

    manageMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDesc = new ImageIcon(url, "Descriptions");
    mItem = new JMenuItem("Table Descriptions...");
    mItem.setIcon(iconDesc);
    mItem.addActionListener(new TableDescriptionActionListener());
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconImport = new ImageIcon(url, "Import");
    mItem = new JMenuItem("Import Data...");
    mItem.setIcon(iconImport);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (workspace.databaseOpened()) {
                ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(),
                        importExportPath);
                importDialog.setVisible(true);

                if (importDialog.canRun()) {
                    importExportPath = importDialog.getCurrentDirectory();
                    workspace.runProcess(importDialog.getCommand());
                }
            } else {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconExport = new ImageIcon(url, "Export");
    mItem = new JMenuItem("Export Data...");
    mItem.setIcon(iconExport);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (!workspace.databaseOpened()) {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            } else if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must select a table in the workspace list. \n "
                                + "Select a table to continue the export.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else {
                ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(),
                        tableName, importExportPath);
                if (exportDialog.canRun()) {
                    importExportPath = exportDialog.getCurrentDirectory();
                    workspace.runProcess(exportDialog.getCommand());
                }
            }
        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDeleteTable = new ImageIcon(url, "Delete");
    mItem = new JMenuItem("Delete Table...");
    mItem.setIcon(iconDeleteTable);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (workspace.databaseOpened()) {
                DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this,
                        workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel());
                deleteDialog.setVisible(true);
                if (deleteDialog.canRun()) {
                    int nSelected = deleteDialog.getNumberOfSelectedTables();
                    int answer = JOptionPane.NO_OPTION;
                    if (nSelected > 1) {
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete these " + nSelected + " tables? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    } else {
                        ArrayList<DataTableName> dList = deleteDialog.getSelectedTables();
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete the table " + dList.get(0).getTableName() + "? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    }
                    if (answer == JOptionPane.YES_OPTION) {
                        workspace.runProcess(deleteDialog.getCommand());
                    }

                }
            } else {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    manageMenu.add(mItem);

    manageMenu.addSeparator();

    SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess();
    subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList);

    SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess();
    subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables");
    mItem = new JMenuItem("Delete Variables...");
    mItem.setIcon(iconDeleteVariables);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (!workspace.databaseOpened()) {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            } else if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must select a table in the workspace list. \n " + "Select a table to continue.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else if (workspace.tableOpen()) {
                DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this,
                        workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables());
                deleteVariableDialog.setVisible(true);
                if (deleteVariableDialog.canRun()) {
                    int nSelected = deleteVariableDialog.getNumberOfSelectedVariables();
                    int answer = JOptionPane.NO_OPTION;
                    if (nSelected > 1) {
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete these " + nSelected + " variables? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    } else {
                        VariableAttributes v = deleteVariableDialog.getSelectedVariable();
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete the variable " + v.getName().toString() + "? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    }
                    if (answer == JOptionPane.YES_OPTION) {
                        workspace.runProcess(deleteVariableDialog.getCommand());
                    }
                }
            }

        }
    });
    manageMenu.add(mItem);

    menuBar.add(manageMenu);

    //============================================================================================
    // Transform Menu
    //============================================================================================
    JMenu transformMenu = new JMenu("Transform");
    transformMenu.setMnemonic('t');

    BasicScoringProcess basicScoringProcess = new BasicScoringProcess();
    basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    ScoringProcess scoringProcess = new ScoringProcess();
    scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    transformMenu.addSeparator();

    RankingProcess rankingProcess = new RankingProcess();
    rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    TestScalingProcess testScalingProcess = new TestScalingProcess();
    testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess();
    linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    transformMenu.addSeparator();

    IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess();
    irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess();
    irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    menuBar.add(transformMenu);

    //============================================================================================
    // Analyze Menu
    //============================================================================================
    JMenu analyzeMenu = new JMenu("Analyze");
    analyzeMenu.setMnemonic('a');

    FrequencyProcess frequencyProcess = new FrequencyProcess();
    frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    DescriptiveProcess descriptiveProcess = new DescriptiveProcess();
    descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    CorrelationProcess correlationProcess = new CorrelationProcess();
    correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    analyzeMenu.addSeparator();

    ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess();
    itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    CmhProcess cmhProcess = new CmhProcess();
    cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    analyzeMenu.addSeparator();

    RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess();
    raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess();
    irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess();
    irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    menuBar.add(analyzeMenu);

    //============================================================================================
    // Graph Menu
    //============================================================================================
    JMenu graphMenu = new JMenu("Graph");
    graphMenu.setMnemonic('g');

    BarChartProcess barchartProcess = new BarChartProcess();
    barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    PieChartProcess piechartProcess = new PieChartProcess();
    piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    graphMenu.addSeparator();

    HistogramProcess histogramProcess = new HistogramProcess();
    histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    DensityProcess densityProcess = new DensityProcess();
    densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    LineChartProcess lineChartProcess = new LineChartProcess();
    lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    ScatterplotProcess scatterplotProcess = new ScatterplotProcess();
    scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    graphMenu.addSeparator();

    NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess();
    nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    mItem = new JMenuItem("Irt Plot...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must open a database and select a table. \n "
                                + "Select a table to continue scoring.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else {
                if (irtPlotDialog == null && workspace.tableOpen()) {

                    //Note that starting this dialog is different because variables
                    //names must be obtained from the rows of a table.

                    DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject();

                    try {
                        ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn(
                                workspace.getConnection(), workspace.getCurrentDataTable(),
                                new VariableName("name"));
                        irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName,
                                tempVar, (SortedListModel<DataTableName>) workspaceList.getModel());
                    } catch (SQLException ex) {
                        logger.fatal(ex.getMessage(), ex);
                        firePropertyChange("error", "", "Error - Check log for details.");
                    }
                }
                if (irtPlotDialog != null)
                    irtPlotDialog.setVisible(true);
            }

            if (irtPlotDialog != null && irtPlotDialog.canRun()) {
                workspace.runProcess(irtPlotDialog.getCommand());
            }
        }
    });
    graphMenu.add(mItem);

    ItemMapProcess itemMapProcess = new ItemMapProcess();
    itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    menuBar.add(graphMenu);

    //============================================================================================
    // Command Menu
    //============================================================================================

    JMenu commandMenu = new JMenu("Commands");
    commandMenu.setMnemonic('c');
    mItem = new JMenuItem("Run command");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent();
            JViewport vp = pain.getViewport();
            Component c = vp.getComponent(0);
            if (c instanceof JmetrikTextFile) {
                JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex());
                JmetrikTextFile textFile = (JmetrikTextFile) c;
                workspace.runFromSyntax(textFile.getText());
            }
        }
    });
    commandMenu.add(mItem);

    mItem = new JMenuItem("Stop command");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //add something
        }
    });
    mItem.setEnabled(false);
    commandMenu.add(mItem);

    mItem = new JMenuItem("Command Reference...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //add something
        }
    });
    mItem.setEnabled(false);
    commandMenu.add(mItem);

    menuBar.add(commandMenu);

    //============================================================================================
    // Help Menu
    //============================================================================================
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('h');
    mItem = new JMenuItem("Quick Start Guide");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Desktop deskTop = Desktop.getDesktop();
            try {
                URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php");
                deskTop.browse(uri);
            } catch (URISyntaxException ex) {
                logger.fatal(ex.getMessage(), ex);
                firePropertyChange("error", "", "Error - Check log for details.");
            } catch (IOException ex) {
                logger.fatal(ex.getMessage(), ex);
                firePropertyChange("error", "", "Error - Check log for details.");
            }
        }
    });
    helpMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconAbout = new ImageIcon(url, "About");
    mItem = new JMenuItem("About");
    mItem.setIcon(iconAbout);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR,
                    RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION);
            aboutDialog.setVisible(true);
        }
    });
    helpMenu.add(mItem);

    menuBar.add(helpMenu);

    return menuBar;
}

From source file:com.declarativa.interprolog.gui.ListenerWindow.java

void constructMenu() {
    JMenuBar mb;//www  .  j a va  2s  . c  o m
    mb = new JMenuBar();
    setJMenuBar(mb);

    final CallsFromArgBuilder2XSB calls2XSB = new CallsFromArgBuilder2XSB();

    /**
     * ****************************************************************
     * ***************ENTRY POINT FOR CALLING THE ARGXSB ANALYSIS *****
     * ****************************************************************
     *
     * Carga un archivo con las reglas para crear los argumentos
     */
    loadRules = new JMenu("");
    loadRules.setMnemonic('A');
    mb.add(loadRules);
    addItemToMenu(loadRules, "Select a Program", 'S', new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            //jLayeredPane1.setVisible(true);
            //WORKFLOW:
            //1. Load File
            //2. clause partition
            //3. graph creation
            //4. extract subgraphs
            //5. create a file for each subgraph
            //6. consult via XSB, each sub-file (sub-graph)
            /**
             * deleteing previous files
             */
            String calls_for_table = "";//maybe temporal
            String returns_for_call = "";

            //the file is loaded
            GraphAnalysis();

            try {
                ReDrawGraph();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
                //System.out.println("EXCEPCION EN REDRAW CALL");
            }

            /*
             //remueve el .P del archivo 
             String nameFile = calls2XSB.File2Consult(getNameOfFileToLoad());
             System.out.println("=============_" + nameFile);
             //StringTokenizer st2 = new StringTokenizer(getNameOfFileToLoad(), ".");
             //String nameFile = st2.nextElement().toString();
             sendCallToProlog("consult(" + nameFile + ").");
                    
                    
             //retorna los valores de True False de cada atomo
             //estos debeian guardarse en la base de datos para luego
             // obtener los argumentos
             calls_for_table = calls2XSB.FindCallsForTable(engine);
             returns_for_call = calls2XSB.FindReturnsForCall(engine);
             */
            java.util.List<String> filenames = new ArrayList();
            filenames = printArguments();

            for (Iterator<String> it = filenames.iterator(); it.hasNext();) {
                String string = it.next();
                //System.out.println("\t\t --------------> name:" + string);
                //System.out.println("\t \t *************************************************");

                /*
                 try {
                 System.out.println(new File(".").getCanonicalPath());
                 System.out.println("DIR:" + new File("../examples/").getCanonicalPath());
                 System.out.println("DIR:" + new File("../examples/"+string).getCanonicalPath());
                        
                 } catch (java.io.IOException ex) {
                 System.out.println("ex." + ex.getLocalizedMessage());
                 }
                 */
                consultFile("../examples/" + string);

                String nameFile3 = calls2XSB.File2Consult(string);
                //sendCallToProlog("consult(" + nameFile3 + ").");
                sendCallToProlog(nameFile3);

                //calls_for_table = calls2XSB.FindCallsForTable(engine);
                //returns_for_call = calls2XSB.FindReturnsForCall(engine, string);
                calls2XSB.WFSEvaluation(engine, string);

                //System.out.println("\t \t *************************************************");
            }

            ArgumentWriter();

            drawArguments();

            /*
             String atomGoal ="p(X)";
             String atomGoal2 = "findall(Y,p(Y), L)";
             String atomGoal3 ="findall(Call,get_calls_for_table(p/1,Call),List)";
             String atomGoal4 ="findall(Answer,get_returns_for_call(p(_),Answer),List2)";
                    
                    
             try {
             String G = "(X=a;X=b)";
             String T = "X";
                       
             String GG = "findall(TM, ("+atomGoal3+",buildTermModel(List,TM)), L), ipObjectSpec('ArrayOfObject',L,LM)";                   
             String GG2 = "findall(TM, ("+atomGoal4+",buildTermModel(List2,TM)), L), ipObjectSpec('ArrayOfObject',L,LM)";
                    
             Object[] bindings0 = engine.deterministicGoal(atomGoal,null);                  
             Object[] bindings = engine.deterministicGoal(atomGoal3,null);
                    
             Object[] get_calls_for_table = (Object[])engine.deterministicGoal(GG,"[LM]")[0];                    
             Object[] get_returns_for_call = (Object[])engine.deterministicGoal(GG2,"[LM]")[0];
                    
             //System.out.println("Number of solutions:"+get_calls_for_table.length);
             for(int I=0;I<get_calls_for_table.length;I++)
             System.out.println("Solution "+I+":"+get_calls_for_table[I]);
                    
             //System.out.println("Number of bindings:"+get_returns_for_call.length);
             for(int I=0;I<get_returns_for_call.length;I++)
             System.out.println("Solution2 "+I+":"+get_returns_for_call[I]);
                      
                    
             } catch (IPAbortedException exc) {
             exc.printStackTrace();
             System.out.println("Exception!: "+exc.getLocalizedMessage());
             } catch (IPInterruptedException ex) {
             ex.printStackTrace();
             System.out.println("Exception!: "+ex.getLocalizedMessage());
             }
                    
             */
        }
    });

    fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');
    //        mb.add(fileMenu);

    addItemToMenu(fileMenu, "Consult...", 'C', new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            reconsultFile();
        }
    });

    if (engine.getImplementationPeer() instanceof XSBPeer) {
        addItemToMenu(fileMenu, "Load dynamically...", 'L', new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                load_dynFile();
            }
        });
    }

    fileMenu.addSeparator();

    JMenu toolMenu = new JMenu("Tools");
    toolMenu.setMnemonic('T');
    //       mb.add(toolMenu);

    final JCheckBoxMenuItem debugging = new JCheckBoxMenuItem("Engine debugging");
    toolMenu.add(debugging);
    debugging.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            engine.setDebug(debugging.isSelected());
        }
    });

    addItemToMenu(toolMenu, "See Object Specifications", 'S', new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            engine.command("showObjectVariables");
        }
    });

    addItemToMenu(toolMenu, "Interrupt Prolog", 'I', new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            engine.interrupt();
        }
    });
    /*
     addItemToMenu(toolMenu,"Serialize JFrame",new ActionListener(){
     public void actionPerformed(ActionEvent e){
     Object [] toSerialize = {new JFrame("My window")};
     engine.setDebug(true);
     System.out.println(engine.deterministicGoal("true","[Object]",toSerialize));
     }
     });*/

    historyMenu = new JMenu("History", true);
    historyMenu.setMnemonic('H');
    //        mb.add(historyMenu);
    historyMenu.addSeparator(); // to avoid Swing bug handling key events
}

From source file:com.digitalgeneralists.assurance.ui.MainWindow.java

private void initializeComponent() {
    if (!this.initialized) {
        logger.info("Initializing the main window.");

        if (AssuranceUtils.getPlatform() == Platform.MAC) {

            System.setProperty("apple.laf.useScreenMenuBar", "true");
            com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication();
            MacApplicationAdapter macAdapter = new MacApplicationAdapter(this);
            macApplication.addApplicationListener(macAdapter);
            macApplication.setEnabledPreferencesMenu(true);
        }/*from   www. ja v  a 2 s  . c o m*/

        this.setTitle(Application.applicationShortName);

        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        this.topArea = new JTabbedPane();

        this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150));

        this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150));

        this.topArea.addTab("Scan", this.scanLaunchPanel);

        this.topArea.addTab("History", this.scanHistoryPanel);

        this.resultsPanel.setPreferredSize(new Dimension(600, 400));

        this.topArea.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                resultsPanel.resetPanel();
                // NOTE:  This isn't ideal.  It feels brittle.
                if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) {
                    viewHistoryMenuItem.setSelected(true);
                } else {
                    viewScanMenuItem.setSelected(true);
                }
            }
        });

        GridBagConstraints topPanelConstraints = new GridBagConstraints();
        topPanelConstraints.anchor = GridBagConstraints.NORTH;
        topPanelConstraints.fill = GridBagConstraints.BOTH;
        topPanelConstraints.gridx = 0;
        topPanelConstraints.gridy = 0;
        topPanelConstraints.weightx = 1.0;
        topPanelConstraints.weighty = 0.33;
        topPanelConstraints.gridheight = 1;
        topPanelConstraints.gridwidth = 1;
        topPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.topArea, topPanelConstraints);

        GridBagConstraints resultsPanelConstraints = new GridBagConstraints();
        resultsPanelConstraints.anchor = GridBagConstraints.SOUTH;
        resultsPanelConstraints.fill = GridBagConstraints.BOTH;
        resultsPanelConstraints.gridx = 0;
        resultsPanelConstraints.gridy = 1;
        resultsPanelConstraints.weightx = 1.0;
        resultsPanelConstraints.weighty = 0.67;
        resultsPanelConstraints.gridheight = 1;
        resultsPanelConstraints.gridwidth = 1;
        resultsPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.resultsPanel, resultsPanelConstraints);

        this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this);
        this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this);

        JMenu menu;
        JMenuItem menuItem;

        menuBar = new JMenuBar();

        StringBuilder accessiblityLabel = new StringBuilder(128);
        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu(Application.applicationShortName);
            menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.quitApplicationAction);
            menu.add(menuItem);

            menu.addSeparator();

            menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel);
            menuItem.getAccessibleContext().setAccessibleDescription(
                    accessiblityLabel.append("Display information about this version of ")
                            .append(Application.applicationShortName).append(".").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.aboutApplicationAction);
            menu.add(menuItem);
        }

        menu = new JMenu("Scan");
        menu.setMnemonic(KeyEvent.VK_S);
        menu.getAccessibleContext().setAccessibleDescription("Actions for file scans");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Launch a scan using the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription(
                "Launch a scan using the selected scan definition and merge the results");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAndMergeAction);
        menu.add(menuItem);

        menu = new JMenu("Results");
        menu.setMnemonic(KeyEvent.VK_R);
        menu.getAccessibleContext().setAccessibleDescription("Actions for scan results");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the source file with the target file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceSourceAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the target file with the source file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceTargetAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.sourceAttributesAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.targetAttributesAction);
        menu.add(menuItem);

        menu = new JMenu("View");
        menu.setMnemonic(KeyEvent.VK_V);
        menu.getAccessibleContext().setAccessibleDescription(
                accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString());
        accessiblityLabel.setLength(0);
        menuBar.add(menu);

        ButtonGroup group = new ButtonGroup();

        this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel);
        this.viewScanMenuItem.addActionListener(this);
        this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction);
        this.viewScanMenuItem.setSelected(true);
        group.add(this.viewScanMenuItem);
        menu.add(this.viewScanMenuItem);

        this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel);
        this.viewHistoryMenuItem.addActionListener(this);
        this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction);
        this.viewHistoryMenuItem.setSelected(true);
        group.add(this.viewHistoryMenuItem);
        menu.add(this.viewHistoryMenuItem);

        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu("Tools");
            menu.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Additional actions for ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Change settings for the ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.displaySettingsAction);
            menu.add(menuItem);
        }

        this.setJMenuBar(menuBar);

        this.initialized = true;
    }
}

From source file:edu.ku.brc.ui.UIRegistry.java

public JMenu createEditMenu() {
    JMenu menu = new JMenu(getResourceString("EDIT"));
    menu.setMnemonic(KeyEvent.VK_E);
    // Undo and redo are actions of our own creation.
    undoAction = (UndoAction) makeAction(UndoAction.class, this, "Undo", null, null, new Integer(KeyEvent.VK_Z),
            KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    register(UNDO, menu.add(undoAction));
    actionMap.put(UNDO, undoAction);/*from  w ww.ja  v a2 s  .c o m*/
    redoAction = (RedoAction) makeAction(RedoAction.class, this, "Redo", null, null, new Integer(KeyEvent.VK_Y),
            KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    register(REDO, menu.add(redoAction));
    actionMap.put(REDO, redoAction);

    menu.addSeparator();
    // These actions come from the default editor kit.  Get the ones we want
    // and stick them in the menu.
    Action cutAction = makeAction(DefaultEditorKit.CutAction.class, null, "Cut", null,
            "Cut selection to clipboard", // I18N ????
            new Integer(KeyEvent.VK_X),
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    register(CUT, menu.add(cutAction));
    cutAction.setEnabled(false);
    actionMap.put(CUT, cutAction);

    Action copyAction = makeAction(DefaultEditorKit.CopyAction.class, null, "Copy", null,
            "Copy selection to clipboard", new Integer(KeyEvent.VK_C),
            KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    register(COPY, menu.add(copyAction));
    copyAction.setEnabled(false);
    actionMap.put(COPY, copyAction);

    Action pasteAction = makeAction(DefaultEditorKit.PasteAction.class, null, "Paste", null,
            "Paste contents of clipboard", new Integer(KeyEvent.VK_V),
            KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    pasteAction.setEnabled(false);
    register(PASTE, menu.add(pasteAction));
    actionMap.put(PASTE, pasteAction);

    /*
    menu.addSeparator();
    Action selectAllAction = makeAction(SelectAllAction.class,
                                   this,
                                   "Select All",
                                   null,
                                   "Select all text",
                                   new Integer(KeyEvent.VK_A),
                                   KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(selectAllAction);
    */
    launchFindReplaceAction = (LaunchFindReplaceAction) makeAction(LaunchFindReplaceAction.class, this, "Find",
            null, null, new Integer(KeyEvent.VK_F),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    //menu.add(launchFindReplaceAction);
    //        launchFindReplaceAction.setEnabled(false);
    //        register(FIND, menu.add(launchFindReplaceAction));
    //        actionMap.put(FIND, launchFindReplaceAction);

    launchFindReplaceAction.setEnabled(false);
    register(FIND, menu.add(launchFindReplaceAction));
    actionMap.put(FIND, launchFindReplaceAction);

    return menu;
}

From source file:com.lfv.lanzius.server.LanziusServer.java

public void init() {

    log.info(Config.VERSION + "\n");

    docVersion = 0;/*w  ww. j  av  a2 s .  c o m*/

    frame = new JFrame(Config.TITLE + " - Server Control Panel");

    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            actionPerformed(new ActionEvent(itemExit, 0, null));
        }
    });

    // Create graphical terminal view
    panel = new WorkspacePanel(this);
    frame.getContentPane().add(panel);

    // Create a menu bar
    JMenuBar menuBar = new JMenuBar();

    // FILE
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    // Load configuration
    itemLoadConfig = new JMenuItem("Load configuration...");
    itemLoadConfig.addActionListener(this);
    fileMenu.add(itemLoadConfig);
    // Load terminal setup
    itemLoadExercise = new JMenuItem("Load exercise...");
    itemLoadExercise.addActionListener(this);
    fileMenu.add(itemLoadExercise);
    fileMenu.addSeparator();
    // Exit
    itemExit = new JMenuItem("Exit");
    itemExit.addActionListener(this);
    fileMenu.add(itemExit);
    menuBar.add(fileMenu);

    // SERVER
    JMenu serverMenu = new JMenu("Server");
    serverMenu.setMnemonic(KeyEvent.VK_S);
    // Start
    itemServerStart = new JMenuItem("Start");
    itemServerStart.addActionListener(this);
    serverMenu.add(itemServerStart);
    // Stop
    itemServerStop = new JMenuItem("Stop");
    itemServerStop.addActionListener(this);
    serverMenu.add(itemServerStop);
    // Restart
    itemServerRestart = new JMenuItem("Restart");
    itemServerRestart.addActionListener(this);
    itemServerRestart.setEnabled(false);
    serverMenu.add(itemServerRestart);
    // Monitor network connection
    itemServerMonitor = new JCheckBoxMenuItem("Monitor network");
    itemServerMonitor.addActionListener(this);
    itemServerMonitor.setState(false);
    serverMenu.add(itemServerMonitor);
    menuBar.add(serverMenu);

    // TERMINAL
    JMenu terminalMenu = new JMenu("Terminal");
    terminalMenu.setMnemonic(KeyEvent.VK_T);
    itemTerminalLink = new JMenuItem("Link...");
    itemTerminalLink.addActionListener(this);
    terminalMenu.add(itemTerminalLink);
    itemTerminalUnlink = new JMenuItem("Unlink...");
    itemTerminalUnlink.addActionListener(this);
    terminalMenu.add(itemTerminalUnlink);
    itemTerminalUnlinkAll = new JMenuItem("Unlink All");
    itemTerminalUnlinkAll.addActionListener(this);
    terminalMenu.add(itemTerminalUnlinkAll);
    itemTerminalSwap = new JMenuItem("Swap...");
    itemTerminalSwap.addActionListener(this);
    terminalMenu.add(itemTerminalSwap);
    menuBar.add(terminalMenu);

    // GROUP
    JMenu groupMenu = new JMenu("Group");
    groupMenu.setMnemonic(KeyEvent.VK_G);
    itemGroupStart = new JMenuItem("Start...");
    itemGroupStart.addActionListener(this);
    groupMenu.add(itemGroupStart);
    itemGroupPause = new JMenuItem("Pause...");
    itemGroupPause.addActionListener(this);
    groupMenu.add(itemGroupPause);
    itemGroupStop = new JMenuItem("Stop...");
    itemGroupStop.addActionListener(this);
    groupMenu.add(itemGroupStop);
    menuBar.add(groupMenu);

    frame.setJMenuBar(menuBar);

    GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds();

    if (Config.SERVER_SIZE_FULLSCREEN) {
        maximumWindowBounds.setLocation(0, 0);
        maximumWindowBounds.setSize(Toolkit.getDefaultToolkit().getScreenSize());
        frame.setResizable(false);
        frame.setUndecorated(true);
    } else if (Config.SERVER_SIZE_100P_WINDOW) {
        // Fixes a bug in linux using gnome. With the line below the upper and
        // lower bars are respected
        maximumWindowBounds.height -= 1;
    } else if (Config.SERVER_SIZE_75P_WINDOW) {
        maximumWindowBounds.width *= 0.75;
        maximumWindowBounds.height *= 0.75;
    } else if (Config.SERVER_SIZE_50P_WINDOW) {
        maximumWindowBounds.width /= 2;
        maximumWindowBounds.height /= 2;
    }

    frame.setBounds(maximumWindowBounds);
    frame.setVisible(true);

    log.info("Starting control panel");

    // Autostart for debugging
    if (Config.SERVER_AUTOLOAD_CONFIGURATION != null)
        actionPerformed(new ActionEvent(itemLoadConfig, 0, null));

    if (Config.SERVER_AUTOSTART_SERVER)
        actionPerformed(new ActionEvent(itemServerStart, 0, null));

    if (Config.SERVER_AUTOLOAD_EXERCISE != null)
        actionPerformed(new ActionEvent(itemLoadExercise, 0, null));

    if (Config.SERVER_AUTOSTART_GROUP > 0)
        actionPerformed(new ActionEvent(itemGroupStart, 0, null));

    try {
        // Read the property files
        serverProperties = new Properties();
        serverProperties.loadFromXML(new FileInputStream("data/properties/serverproperties.xml"));
        int rcPort = Integer.parseInt(serverProperties.getProperty("RemoteControlPort", "0"));
        if (rcPort > 0) {
            groupRemoteControlListener(rcPort);
        }
        isaPeriod = Integer.parseInt(serverProperties.getProperty("ISAPeriod", "60"));
        isaNumChoices = Integer.parseInt(serverProperties.getProperty("ISANumChoices", "6"));
        for (int i = 0; i < 9; i++) {
            String tag = "ISAKeyText" + Integer.toString(i);
            String def_val = Integer.toString(i + 1);
            isakeytext[i] = serverProperties.getProperty(tag, def_val);
        }
        isaExtendedMode = serverProperties.getProperty("ISAExtendedMode", "false").equalsIgnoreCase("true");
    } catch (Exception e) {
        log.error("Unable to start remote control listener");
        log.error(e.getMessage());
    }
    isaClients = new HashSet<Integer>();
}

From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java

/**
 * Build main menu.//  w  w w.  j a va  2 s  .  c o  m
 * 
 * @param spiders
 */
private void buildMenu(final SpidersGraph spiders) {
    JMenuBar menuBar;
    JMenu menu, submenu;
    JMenuItem menuItem, subMenuItem;
    JRadioButtonMenuItem rbMenuItem;

    // create the menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // - main menu -------------------------------------------------------
    menu = new JMenu(MindRaiderConstants.MR_TITLE);
    menu.setMnemonic(KeyEvent.VK_M);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.setActiveNotebookAsHome"));
    menuItem.setMnemonic(KeyEvent.VK_H);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.profile.setHomeNotebook();
        }
    });
    menu.add(menuItem);
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.preferences"));
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new PreferencesJDialog();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.exit"), KeyEvent.VK_X);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            exitMindRaider();
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - Find ----------------------------------------------------------

    menu = new JMenu(Messages.getString("MindRaiderJFrame.search"));
    menu.setMnemonic(KeyEvent.VK_F);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchNotebooks"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new OpenOutlineJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchFulltext"));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new FtsJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsInNotebook"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutlineUri() != null) {
                new OpenNoteJDialog();
            }
        }
    });
    menu.add(menuItem);

    // search by tag
    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsByTag"));
    menuItem.setEnabled(true);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new OpenConceptByTagJDialog();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.previousNote"));
    menuItem.setEnabled(true);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MindRaider.recentConcepts.moveOneNoteBack();
        }
    });
    menu.add(menuItem);

    // global RDF search
    //        menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchRdql"));
    //        menuItem.setEnabled(false);
    //        menuItem.setMnemonic(KeyEvent.VK_R);
    //        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
    //                ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    //        menuItem.addActionListener(new ActionListener() {
    //
    //            public void actionPerformed(ActionEvent e) {
    //                // TODO rdql to be implemented
    //            }
    //        });
    //        menu.add(menuItem);

    menuBar.add(menu);

    // - view ------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.view"));
    menu.setMnemonic(KeyEvent.VK_V);

    // TODO localize L&F menu
    ButtonGroup lfGroup = new ButtonGroup();
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.lookAndFeel"));
    logger.debug("Look and feel is: " + MindRaider.profile.getLookAndFeel()); // {{debug}}
    submenu.setMnemonic(KeyEvent.VK_L);
    subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelNative"));
    if (MindRaider.LF_NATIVE.equals(MindRaider.profile.getLookAndFeel())) {
        subMenuItem.setSelected(true);
    }
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            setLookAndFeel(MindRaider.LF_NATIVE);
        }
    });
    submenu.add(subMenuItem);
    lfGroup.add(subMenuItem);
    subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelJava"));
    if (MindRaider.LF_JAVA_DEFAULT.equals(MindRaider.profile.getLookAndFeel())) {
        subMenuItem.setSelected(true);
    }
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            setLookAndFeel(MindRaider.LF_JAVA_DEFAULT);
        }
    });
    submenu.add(subMenuItem);
    lfGroup.add(subMenuItem);
    menu.add(submenu);

    menu.addSeparator();
    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.leftSideBar"));
    menuItem.setMnemonic(KeyEvent.VK_L);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (leftSidebarSplitPane.getDividerLocation() == 1) {
                leftSidebarSplitPane.resetToPreferredSizes();
            } else {
                closeLeftSidebar();
            }
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rightSideBar"));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().toggleRightSidebar();
        }
    });
    menu.add(menuItem);

    // TODO tips to be implemented
    // JCheckBoxMenuItem helpCheckbox=new JCheckBoxMenuItem("Tips",true);
    // menu.add(helpCheckbox);

    // TODO localize
    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.toolbar"));
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.masterToolBar.toggleVisibility();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rdfNavigatorDashboard"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.spidersGraph.getGlPanel().toggleControlPanel();
        }
    });
    menu.add(menuItem);

    JCheckBoxMenuItem checkboxMenuItem;
    ButtonGroup colorSchemeGroup;

    //        if (!MindRaider.OUTLINER_PERSPECTIVE.equals(MindRaider.profile
    //                .getUiPerspective())) {

    menu.addSeparator();

    // Facets
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.facet"));
    submenu.setMnemonic(KeyEvent.VK_F);
    colorSchemeGroup = new ButtonGroup();

    String[] facetLabels = FacetCustodian.getInstance().getFacetLabels();
    if (!ArrayUtils.isEmpty(facetLabels)) {
        for (String facetLabel : facetLabels) {
            rbMenuItem = new JRadioButtonMenuItem(facetLabel);
            rbMenuItem.addActionListener(new FacetActionListener(facetLabel));
            colorSchemeGroup.add(rbMenuItem);
            submenu.add(rbMenuItem);
            if (BriefFacet.LABEL.equals(facetLabel)) {
                rbMenuItem.setSelected(true);
            }
        }

    }
    menu.add(submenu);

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.graphLabelAsUri"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_G);
    checkboxMenuItem.setState(MindRaider.spidersGraph.isUriLabels());
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                MindRaider.spidersGraph.setUriLabels(j.getState());
                MindRaider.spidersGraph.renderModel();
                MindRaider.profile.setGraphShowLabelsAsUris(j.getState());
                MindRaider.profile.save();
            }
        }
    });

    menu.add(checkboxMenuItem);

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.predicateNodes"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_P);
    checkboxMenuItem.setState(!MindRaider.spidersGraph.getHidePredicates());
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                MindRaider.spidersGraph.hidePredicates(!j.getState());
                MindRaider.spidersGraph.renderModel();
                MindRaider.profile.setGraphHidePredicates(!j.getState());
                MindRaider.profile.save();
            }
        }
    });
    menu.add(checkboxMenuItem);

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.multilineLabels"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_M);
    checkboxMenuItem.setState(MindRaider.spidersGraph.isMultilineNodes());
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                MindRaider.spidersGraph.setMultilineNodes(j.getState());
                MindRaider.spidersGraph.renderModel();
                MindRaider.profile.setGraphMultilineLabels(j.getState());
                MindRaider.profile.save();
            }
        }
    });
    menu.add(checkboxMenuItem);
    //        }

    menu.addSeparator();

    // Antialias
    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.antiAliased"), true);
    checkboxMenuItem.setMnemonic(KeyEvent.VK_A);
    checkboxMenuItem.setState(SpidersGraph.antialiased);
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                SpidersGraph.antialiased = j.getState();
                MindRaider.spidersGraph.renderModel();
            }
        }
    });
    menu.add(checkboxMenuItem);

    // Enable hyperbolic
    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.hyperbolic"), true);
    checkboxMenuItem.setMnemonic(KeyEvent.VK_H);
    checkboxMenuItem.setState(SpidersGraph.hyperbolic);
    checkboxMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                SpidersGraph.hyperbolic = j.getState();
                MindRaider.spidersGraph.renderModel();
            }
        }
    });
    menu.add(checkboxMenuItem);

    // Show FPS
    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fps"), true);
    checkboxMenuItem.setMnemonic(KeyEvent.VK_F);
    checkboxMenuItem.setState(SpidersGraph.fps);
    checkboxMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                SpidersGraph.fps = j.getState();
                MindRaider.spidersGraph.renderModel();
            }
        }
    });
    menu.add(checkboxMenuItem);

    // Graph color scheme
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorScheme"));
    submenu.setMnemonic(KeyEvent.VK_C);
    String[] allProfilesUris = MindRaider.spidersColorProfileRegistry.getAllProfilesUris();
    colorSchemeGroup = new ButtonGroup();
    for (int i = 0; i < allProfilesUris.length; i++) {
        rbMenuItem = new UriJRadioButtonMenuItem(
                MindRaider.spidersColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(),
                allProfilesUris[i]);
        rbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() instanceof UriJRadioButtonMenuItem) {
                    MindRaider.spidersColorProfileRegistry
                            .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri);
                    MindRaider.spidersGraph
                            .setRenderingProfile(MindRaider.spidersColorProfileRegistry.getCurrentProfile());
                    MindRaider.spidersGraph.renderModel();
                }
            }
        });
        colorSchemeGroup.add(rbMenuItem);
        submenu.add(rbMenuItem);
    }
    menu.add(submenu);

    // Annotation color scheme
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorSchemeAnnotation"));
    submenu.setMnemonic(KeyEvent.VK_A);
    allProfilesUris = MindRaider.annotationColorProfileRegistry.getAllProfilesUris();
    colorSchemeGroup = new ButtonGroup();
    for (int i = 0; i < allProfilesUris.length; i++) {
        rbMenuItem = new UriJRadioButtonMenuItem(
                MindRaider.annotationColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(),
                allProfilesUris[i]);
        rbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() instanceof UriJRadioButtonMenuItem) {
                    MindRaider.annotationColorProfileRegistry
                            .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri);
                    OutlineJPanel.getInstance().conceptJPanel.refresh();
                }
            }
        });
        colorSchemeGroup.add(rbMenuItem);
        submenu.add(rbMenuItem);
    }
    menu.add(submenu);

    menu.addSeparator();

    checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fullScreen"));
    checkboxMenuItem.setMnemonic(KeyEvent.VK_U);
    checkboxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0));
    checkboxMenuItem.setState(false);
    checkboxMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof JCheckBoxMenuItem) {
                JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource();
                if (j.getState()) {
                    Gfx.toggleFullScreen(MindRaiderMainWindow.this);
                } else {
                    Gfx.toggleFullScreen(null);
                }
            }
        }
    });
    menu.add(checkboxMenuItem);

    menuBar.add(menu);

    // - outline
    // ----------------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.notebook"));
    menu.setMnemonic(KeyEvent.VK_N);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.newNotebook"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // TODO clear should be optional - only if creation finished
            // MindRider.spidersGraph.clear();
            new NewOutlineJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new OpenOutlineJDialog();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.close"));
    menuItem.setMnemonic(KeyEvent.VK_C);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MindRaider.outlineCustodian.close();
            OutlineJPanel.getInstance().refresh();
            MindRaider.spidersGraph.renderModel();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.setEnabled(false); // TODO discard method must be implemented
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int result = JOptionPane.showConfirmDialog(MindRaiderMainWindow.this, Messages.getString(
                    "MindRaiderJFrame.confirmDiscardNotebook", MindRaider.profile.getActiveOutline()));
            if (result == JOptionPane.YES_OPTION) {
                if (MindRaider.profile.getActiveOutlineUri() != null) {
                    try {
                        MindRaider.labelCustodian
                                .discardOutline(MindRaider.profile.getActiveOutlineUri().toString());
                        MindRaider.outlineCustodian.close();
                    } catch (Exception e1) {
                        logger.error(Messages.getString("MindRaiderJFrame.unableToDiscardNotebook"), e1);
                    }
                }
            }
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    // export
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.export"));
    submenu.setMnemonic(KeyEvent.VK_E);
    // Atom
    subMenuItem = new JMenuItem("Atom");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            exportActiveOutlineToAtom();
        }
    });
    submenu.add(subMenuItem);

    // OPML
    subMenuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.opml"));
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(MindRaiderMainWindow.this,
                        Messages.getString("MindRaiderJFrame.exportNotebookWarning"),
                        Messages.getString("MindRaiderJFrame.exportError"),

                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export"
                    + File.separator + "opml";
            Utils.createDirectory(exportDirectory);
            fc.setCurrentDirectory(new File(exportDirectory));
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "OPML-EXPORT-"
                        + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".xml";
                logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName));
                MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML, dstFileName);
                Launcher.launchViaStart(dstFileName);
            } else {
                logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser"));
            }
        }
    });
    submenu.add(subMenuItem);
    // TWiki
    subMenuItem = new JMenuItem("TWiki");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutline() == null) {
                JOptionPane.showMessageDialog(MindRaiderMainWindow.this,
                        Messages.getString("MindRaiderJFrame.exportNotebookWarning"),
                        Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE);
                return;
            }

            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export"
                    + File.separator + "twiki";
            Utils.createDirectory(exportDirectory);
            fc.setCurrentDirectory(new File(exportDirectory));
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator
                        + "TWIKI-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".txt";
                logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName));

                MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName);
            } else {
                logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser"));
            }
        }
    });
    submenu.add(subMenuItem);

    menu.add(submenu);

    // import
    submenu = new JMenu(Messages.getString("MindRaiderJFrame.import"));
    submenu.setMnemonic(KeyEvent.VK_I);

    subMenuItem = new JMenuItem("Atom");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            importFromAtom();
        }
    });
    submenu.add(subMenuItem);

    // TWiki
    subMenuItem = new JMenuItem("TWiki");
    subMenuItem.setEnabled(true);
    subMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            // choose file to be transformed
            OutlineJPanel.getInstance().clear();
            MindRaider.profile.setActiveOutlineUri(null);
            JFileChooser fc = new JFileChooser();
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final File file = fc.getSelectedFile();
                MindRaider.profile.deleteActiveModel();
                logger.debug(
                        Messages.getString("MindRaiderJFrame.importingTWikiTopic", file.getAbsolutePath()));

                // perform it async
                final SwingWorker worker = new SwingWorker() {

                    public Object construct() {
                        ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame(
                                Messages.getString("MindRaiderJFrame.twikiImport"),
                                Messages.getString("MindRaiderJFrame.processingTopicTWiki"));
                        try {
                            MindRaider.outlineCustodian.importNotebook(OutlineCustodian.FORMAT_TWIKI,
                                    (file != null ? file.getAbsolutePath() : null), progressDialogJFrame);
                        } finally {
                            if (progressDialogJFrame != null) {
                                progressDialogJFrame.dispose();
                            }
                        }
                        return null;
                    }
                };
                worker.start();
            } else {
                logger.debug(Messages.getString("MindRaiderJFrame.openCommandCancelledByUser"));
            }
        }
    });
    submenu.add(subMenuItem);

    menu.add(submenu);

    menuBar.add(menu);

    // - note
    // ----------------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.concept"));
    menu.setMnemonic(KeyEvent.VK_C);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.new"));
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().newConcept();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (MindRaider.profile.getActiveOutlineUri() != null) {
                new OpenNoteJDialog();
            }
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard"));
    // do not accelerate this command with DEL - it's already handled
    // elsewhere
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptDiscard();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.up"));
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptUp();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.promote"));
    menuItem.setMnemonic(KeyEvent.VK_P);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptPromote();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.demote"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptDemote();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.down"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.CTRL_MASK));
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            OutlineJPanel.getInstance().conceptDown();
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - Tools -----------------------------------------------------------

    menu = new JMenu(Messages.getString("MindRaiderJFrame.tools"));
    menu.setMnemonic(KeyEvent.VK_T);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.checkAndFix"));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Checker.checkAndFixRepositoryAsync();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.backupRepository"));
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Installer.backupRepositoryAsync();
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rebuildSearchIndex"));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchCommander.rebuildSearchAndTagIndices();
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.captureScreen"));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.screenshot"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseScreenshotDirectory"));
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            // prepare directory
            String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "Screenshots";
            Utils.createDirectory(exportDirectory);
            fc.setCurrentDirectory(new File(exportDirectory));
            int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final String filename = fc.getSelectedFile().getAbsolutePath() + File.separator
                        + "screenshot.jpg";

                // do it in async (redraw screen)
                Thread thread = new Thread() {
                    public void run() {
                        OutputStream file = null;
                        try {
                            file = new FileOutputStream(filename);

                            Robot robot = new Robot();
                            robot.delay(1000);

                            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file);
                            encoder.encode(robot.createScreenCapture(
                                    new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())));
                        } catch (Exception e1) {
                            logger.error("Unable to capture screen!", e1);
                        } finally {
                            if (file != null) {
                                try {
                                    file.close();
                                } catch (IOException e1) {
                                    logger.error("Unable to close stream", e1);
                                }
                            }
                        }
                    }
                };
                thread.setDaemon(true);
                thread.start();

            }
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - MindForger -----------------------------------------------------------

    menu = new JMenu(Messages.getString("MindRaiderMainWindow.menuMindForger"));
    menu.setMnemonic(KeyEvent.VK_O);
    //menu.setIcon(IconsRegistry.getImageIcon("tasks-internet.png"));

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerVideoTutorial"));
    menuItem.setMnemonic(KeyEvent.VK_G);
    menuItem.setToolTipText("http://mindraider.sourceforge.net/mindforger.html");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://mindraider.sourceforge.net/mindforger.html");
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.signUp"));
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setToolTipText("http://www.mindforger.com");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://www.mindforger.com");
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerUpload"));
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // fork in order to enable status updates in the main window
            new MindForgerUploadOutlineJDialog();
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerDownload"));
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            downloadAnOutlineFromMindForger();
        }
    });
    menuItem.setEnabled(true);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerMyOutlines"));
    menuItem.setMnemonic(KeyEvent.VK_O);
    menuItem.setEnabled(true);
    menuItem.setToolTipText("http://web.mindforger.com");
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://web.mindforger.com");
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);

    // - align Help on right -------------------------------------------------------------

    menuBar.add(Box.createHorizontalGlue());

    // - help -------------------------------------------------------------
    menu = new JMenu(Messages.getString("MindRaiderJFrame.help"));
    menu.setMnemonic(KeyEvent.VK_H);

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.documentation"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                MindRaider.outlineCustodian.loadOutline(new URI(MindRaiderVocabulary
                        .getNotebookUri(OutlineCustodian.MR_DOC_NOTEBOOK_DOCUMENTATION_LOCAL_NAME)));
                OutlineJPanel.getInstance().refresh();
            } catch (Exception e1) {
                logger.error(Messages.getString("MindRaiderJFrame.unableToLoadHelp", e1.getMessage()));
            }
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.webHomepage"));
    menuItem.setMnemonic(KeyEvent.VK_H);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://mindraider.sourceforge.net");
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.reportBug"));
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Launcher.launchInBrowser("http://sourceforge.net/forum/?group_id=128454");
        }
    });
    menu.add(menuItem);

    menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.updateCheck"));
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setEnabled(true);
    menuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // just open html page at:
            //   http://mindraider.sourceforge.net/update-7.2.html
            // this page will either contain "you have the last version" or will ask user to
            // download the latest version from main page
            Launcher.launchInBrowser("http://mindraider.sourceforge.net/" + "update-"
                    + MindRaiderConstants.majorVersion + "." + MindRaiderConstants.minorVersion + ".html");
        }
    });
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.about", MindRaiderConstants.MR_TITLE));
    menuItem.setMnemonic(KeyEvent.VK_A);
    menuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            new AboutJDialog();
        }
    });
    menu.add(menuItem);

    menuBar.add(menu);
}

From source file:corelyzer.ui.CorelyzerApp.java

private void setupMenuStuff() {
    menuBar = new JMenuBar();

    // Create File Menu
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    JMenuItem createSessionMenuItem = new JMenuItem("Create a Session", KeyEvent.VK_N);
    createSessionMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_MASK));
    createSessionMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.createSession();/* ww  w  .  ja  v  a2  s.  co  m*/
        }
    });
    createSessionMenuItem.setEnabled(true);
    fileMenu.add(createSessionMenuItem);

    createTrackMenuItem = new JMenuItem("Create a Track", KeyEvent.VK_T);
    createTrackMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, MENU_MASK));
    createTrackMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.createTrack();
        }
    });
    createTrackMenuItem.setEnabled(false);
    fileMenu.add(createTrackMenuItem);

    fileMenu.addSeparator();

    // Images
    JMenu loadImageMenu = new JMenu("Load Images");
    loadImageMenuItem = new JMenuItem("Open Local Image Files...", KeyEvent.VK_M);
    loadImageMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, MENU_MASK));
    loadImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.loadImageAction();
        }
    });
    loadImageMenu.add(loadImageMenuItem);

    // "Auto-load" 4/25/2012 brg
    JMenuItem autoLoadImageMenuItem = new JMenuItem("Open Image Listing...");
    autoLoadImageMenuItem.setEnabled(true);
    autoLoadImageMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.loadImageListingAction();
        }
    });
    loadImageMenu.add(autoLoadImageMenuItem);

    // online image services
    JMenuItem chronosMenuItem = new JMenuItem("Online Image Services...");
    loadImageMenu.add(chronosMenuItem);
    chronosMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(1);
            d.setVisible(true);
        }
    });

    fileMenu.add(loadImageMenu);

    // Numbercal data (plots)
    JMenu loadDataMenu = new JMenu("Load Data");

    loadDataMenuItem = new JMenuItem("Open Local Dataset Files", KeyEvent.VK_D);
    loadDataMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, MENU_MASK));
    loadDataMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            Runnable r = new Runnable() {
                public void run() {
                    controller.loadData();
                }
            };

            new Thread(r).start();
        }
    });
    loadDataMenu.add(loadDataMenuItem);
    fileMenu.add(loadDataMenu);

    JMenuItem quickDataImportMenuItem = new JMenuItem("Quick Data Import...");
    quickDataImportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.quickDataImport();
        }
    });
    loadDataMenu.add(quickDataImportMenuItem);

    JMenuItem importDataMenuItem = new JMenuItem("Custom Data Import...");
    importDataMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.importData();
        }
    });
    loadDataMenu.add(importDataMenuItem);

    // LoggingDB
    JMenuItem loggingDBMenuItem = new JMenuItem("LDEO logging DB...");
    loggingDBMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(2);
            d.setVisible(true);
        }
    });
    loadDataMenu.add(loggingDBMenuItem);

    fileMenu.addSeparator();

    loadStateFileMenuItem = new JMenuItem("Open a Session File", KeyEvent.VK_O);
    loadStateFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_MASK));
    loadStateFileMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.loadStateFile();
        }
    });
    loadStateFileMenuItem.setEnabled(false);
    fileMenu.add(loadStateFileMenuItem);

    JMenuItem saveMenuItem = new JMenuItem("Save Session", KeyEvent.VK_S);
    saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK));
    saveMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            controller.saveCurrentSession();
        }
    });
    fileMenu.add(saveMenuItem);

    JMenuItem saveStateToFileMenuItem = new JMenuItem("Save Session As...", KeyEvent.VK_S);
    saveStateToFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_MASK));
    saveStateToFileMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.saveStateToFile();
        }
    });
    fileMenu.add(saveStateToFileMenuItem);

    // Session History
    recentSessionsMenu = new JMenu("Recent Sessions");
    controller.refreshSessionHistoryMenu();
    fileMenu.add(recentSessionsMenu);

    fileMenu.addSeparator();

    JMenu packageMenu = new JMenu("Core Archive");
    JMenuItem importMenuItem = new JMenuItem("Import...");
    importMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.importPackage();
        }
    });
    packageMenu.add(importMenuItem);

    JMenuItem exportMenuItem = new JMenuItem("Export...");
    exportMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.exportTheWholeScene();
        }
    });
    packageMenu.add(exportMenuItem);
    fileMenu.add(packageMenu);

    JMenu limsMenu = new JMenu("IODP");

    JMenuItem allIODPLists = new JMenuItem("All IODP lists...");
    allIODPLists.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });
    limsMenu.add(allIODPLists);

    JMenuItem loadLIMSTables = new JMenuItem("Load a section list...");
    loadLIMSTables.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.loadLIMSTables(getMainFrame());

            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(0);
            d.setVisible(true);
        }
    });
    limsMenu.add(loadLIMSTables);

    JMenuItem loadAffineTable = new JMenuItem("Load an affine table...");
    loadAffineTable.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.loadAAffineTable(getMainFrame());

            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(3);
            d.setVisible(true);
        }
    });
    limsMenu.add(loadAffineTable);

    JMenuItem loadSpliceTable = new JMenuItem("Load a splice table...");
    loadSpliceTable.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.loadASpliceTable(getMainFrame());

            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisibleTab(4);
            d.setVisible(true);
        }
    });
    limsMenu.add(loadSpliceTable);

    fileMenu.add(limsMenu);

    JMenu disMenu = new JMenu("DIS");

    JMenuItem disListMenuItem = new JMenuItem("Accessing DIS...");
    disListMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            DISListsDialog d = new DISListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });

    JMenuItem disImport = new JMenuItem("Import...");
    disImport.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.disImport();
        }
    });
    JMenuItem disExport = new JMenuItem("Export...");
    disExport.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.disExport();
        }
    });

    JMenuItem disBatchDataLoad = new JMenuItem("Load Tab Delimited Data File...");
    disBatchDataLoad.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.disBatchDataLoad();
        }
    });

    disMenu.add(disListMenuItem);
    disMenu.add(disImport);
    disMenu.add(disExport);
    disMenu.add(disBatchDataLoad);
    fileMenu.add(disMenu);

    JMenuItem saveOutputToFileMenuItem = new JMenuItem("Export Sheets...", KeyEvent.VK_A);
    saveOutputToFileMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.saveOutputToFile();
        }
    });
    fileMenu.add(saveOutputToFileMenuItem);

    fileMenu.addSeparator();

    JMenuItem quitMenuItem = new JMenuItem("Quit");
    fileMenu.add(quitMenuItem);
    quitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, MENU_MASK));
    quitMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.quit();
        }
    });

    menuBar.add(fileMenu);

    // Create Edit Menu
    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic(KeyEvent.VK_E);

    JMenuItem clearImageCacheMenuItem = new JMenuItem("Clear Image Cache...", KeyEvent.VK_I);
    clearImageCacheMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.clearImageCache();
        }
    });
    editMenu.add(clearImageCacheMenuItem);

    editMenu.addSeparator();
    JMenuItem depthDirection = new JMenuItem("Switch Depth Direction", KeyEvent.VK_K);
    depthDirection.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, MENU_MASK));
    depthDirection.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            boolean b = SceneGraph.getDepthOrientation();
            SceneGraph.setDepthOrientation(!b);

            CorelyzerApp.getApp().updateGLWindows();
        }
    });
    editMenu.add(depthDirection);

    JMenuItem tour = new JMenuItem("Tour...");
    tour.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            CRNavigationSetupDialog dlg = new CRNavigationSetupDialog();
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });

    editMenu.add(tour);

    editMenu.addSeparator();
    JMenuItem preferencesMenuItem = new JMenuItem("Preferences...");
    editMenu.add(preferencesMenuItem);
    preferencesMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.doPreferences();
        }
    });

    menuBar.add(editMenu);

    // Create Share Menu
    JMenu shareMenu = new JMenu("Share");

    JMenuItem publishMenuItem = new JMenuItem("Publish...");
    publishMenuItem.setEnabled(true);
    publishMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.publishASession();
        }
    });
    shareMenu.add(publishMenuItem);

    JMenuItem listMenuItem = new JMenuItem("List...");
    listMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            controller.listSessions();
        }
    });
    shareMenu.add(listMenuItem);

    shareMenu.addSeparator();

    friendsMenu = new JMenu("Friends");
    shareMenu.add(friendsMenu);

    menuBar.add(shareMenu);

    // Create Debug Menu
    JMenu debugMenu = new JMenu("Debug");
    debugMenu.setMnemonic(KeyEvent.VK_D);

    JMenuItem matchTestMenuItem = new JMenuItem("Match-Test", KeyEvent.VK_B);
    matchTestMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent event) {
            controller.testAndMatch();
        }
    });

    debugMenu.add(matchTestMenuItem);

    if ((System.getenv("DEBUG") != null) && System.getenv("DEBUG").equals("YES")) {
        menuBar.add(shareMenu);
    }

    // Create the Plugin Menu
    pluginMenu = new JMenu("Plugins");
    menuBar.add(pluginMenu);
    pluginMenuItemVec = new Vector<JMenuItem>();

    // Lists
    JMenu listsMenu = new JMenu("Lists");

    JMenuItem iodpLists = new JMenuItem("IODP lists...");
    iodpLists.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            IODPListsDialog d = new IODPListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });
    listsMenu.add(iodpLists);

    JMenuItem disLists = new JMenuItem("DIS lists...");
    disLists.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            DISListsDialog d = new DISListsDialog(getMainFrame());
            d.pack();
            d.setSize(800, 600);
            d.setLocationRelativeTo(getMainFrame());
            d.setVisible(true);
        }
    });
    listsMenu.add(disLists);

    JMenu annotLists = new JMenu("Annotation");

    JMenuItem freeformsItem = new JMenuItem("Default");
    freeformsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            FreeformAnnotationListDialog dlg = new FreeformAnnotationListDialog(getApp().getMainFrame());
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());
            dlg.onRefresh();

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });
    annotLists.add(freeformsItem);

    JMenuItem clastListItem = new JMenuItem("Clast");
    clastListItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            ClastStatisticsDialog dlg = new ClastStatisticsDialog(getApp().getMainFrame());
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());
            dlg.onRefresh();

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });
    annotLists.add(clastListItem);

    JMenuItem sampleReqsItem = new JMenuItem("Sample");
    sampleReqsItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            SampleRequestListDialog dlg = new SampleRequestListDialog(getApp().getMainFrame());
            dlg.pack();
            dlg.setLocationRelativeTo(getApp().getMainFrame());
            dlg.onRefresh();

            dlg.setAlwaysOnTop(true);
            dlg.setVisible(true);
        }
    });
    annotLists.add(sampleReqsItem);
    listsMenu.add(annotLists);

    menuBar.add(listsMenu);

    // Create Tools Menu
    JMenu toolsMenu = new JMenu("Tools");
    JMenuItem wholeCoreViewerMenuItem = new JMenuItem("Get 3D Whole Core Imagery Viewer...");
    wholeCoreViewerMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            try {
                String app;
                String url = "http://www.evl.uic.edu/cavern/corewall/SciVizCore/";

                if (System.getProperty("os.name").toLowerCase().contains("windows")) {
                    app = "cmd.exe /c explorer " + url;
                    Runtime.getRuntime().exec(app);
                } else {
                    app = "open";
                    String[] cmd = { app, url };
                    Runtime.getRuntime().exec(cmd);
                }
            } catch (IOException ex) {
                System.err.println("IOException in opening SciVizCore link");
            }
        }
    });

    toolsMenu.add(wholeCoreViewerMenuItem);

    // DEBUG
    String debug = System.getProperty("DEBUG");
    if ((debug != null) && System.getProperty("DEBUG").equals("true")) {
        JMenuItem gcItem = new JMenuItem("GC");
        gcItem.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                long mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("- B4 mem:\t" + mem0 / 1000000.0f);

                int trials = 10000;
                for (int i = 0; i < trials; i++) {
                    updateGLWindows();
                }

                long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("- " + trials + " mem:\t" + mem1 / 1000000.0f);

                System.gc();
                System.gc();
                System.gc();

                long mem2 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("- AferGC mem:\t" + mem2 / 1000000.0f);
            }
        });
        toolsMenu.add(gcItem);
    }

    menuBar.add(toolsMenu);

    // Create Help Menu
    // Create JavaHelp hooks
    File helpSet = new File("help/jhelpset.hs");
    HelpSet hs = null;
    try {
        URL hsURL = helpSet.toURI().toURL();
        hs = new HelpSet(null, hsURL);
    } catch (HelpSetException e) {
        JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: format error.");
        e.printStackTrace();
    } catch (MalformedURLException e) {
        JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: malformed URL.");
        e.printStackTrace();
    }

    // Help UI
    JMenu helpMenu = new JMenu("Help");
    JMenuItem helpMenuItem = new JMenuItem("Help", KeyEvent.VK_H);

    if (hs != null) {
        HelpBroker hb = hs.createHelpBroker();
        helpActionListener = new CSH.DisplayHelpFromSource(hb);
        helpMenuItem.addActionListener(helpActionListener);
    } else {
        helpMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent event) {
                controller.helpAction();
            }
        });
    }
    helpMenu.add(helpMenuItem);

    helpMenu.addSeparator();
    JMenuItem aboutMenuItem = new JMenuItem("About Corelyzer");
    helpMenu.add(aboutMenuItem);
    aboutMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            controller.about();
        }
    });

    menuBar.add(helpMenu);

    mainFrame.setJMenuBar(menuBar);
}