Example usage for java.awt.event KeyEvent VK_N

List of usage examples for java.awt.event KeyEvent VK_N

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_N.

Prototype

int VK_N

To view the source code for java.awt.event KeyEvent VK_N.

Click Source Link

Document

Constant for the "N" key.

Usage

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

private void buildMenu() {
    menu.setMnemonic(KeyEvent.VK_M);

    // menu items
    JMenuItem menuItem = menu.add(actionUpdateDataSources2);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(//from  w  w  w  .  j  av  a2  s. c o m
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$
    menuUpdateDatasources.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuUpdateDatasources.removeAll();
            menuFindMissingMovies.removeAll();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds));
                menuUpdateDatasources.add(item);

                item = new JMenuItem(new MovieFindMissingAction(ds));
                menuFindMissingMovies.add(item);

            }
        }
    });
    menu.add(menuUpdateDatasources);

    menu.add(new MovieFindMissingAction());
    menu.add(menuFindMissingMovies);
    menu.add(new MovieCreateOfflineAction(true));

    menu.addSeparator();

    JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
    menuScrape.setMnemonic(KeyEvent.VK_S);
    menuItem = menuScrape.add(actionScrape2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeSelected);
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeUnscraped);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeMetadataSelected);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuScrape.add(actionAssignMovieSets);
    menu.add(menuScrape);

    JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$
    menuEdit.setMnemonic(KeyEvent.VK_E);
    menuItem = menuEdit.add(actionEditMovie2);
    menuItem.setMnemonic(KeyEvent.VK_E);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionBatchEdit);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionSetWatchedFlag);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRename2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRenamerPreview);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(menuEdit);

    menuItem = menu.add(actionRewriteNfo);
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem = menu.add(actionTrailerDownload);
    menuItem = menu.add(actionSearchSubtitle);
    menuItem = menu.add(actionDownloadSubtitle);

    menu.addSeparator();
    menuItem = menu.add(actionMediaInformation2);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionExport);
    menuItem.setMnemonic(KeyEvent.VK_X);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionRemove2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE));
    menuItem = menu.add(actionDelete2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));
    menu.addSeparator();
    menuItem = menu.add(actionSyncTrakt);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem = menu.add(actionSyncWatchedTrakt);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem = menu.add(actionSyncSelectedTrakt);

    menu.addSeparator();
    menuItem = menu.add(actionClearImageCache);
    menuItem.setMnemonic(KeyEvent.VK_C);

    // popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(actionScrape2);
    popupMenu.add(actionScrapeSelected);
    popupMenu.add(actionScrapeUnscraped);
    popupMenu.add(actionScrapeMetadataSelected);
    popupMenu.add(actionAssignMovieSets);
    popupMenu.addSeparator();
    popupMenu.add(actionEditMovie2);
    popupMenu.add(actionBatchEdit);
    popupMenu.add(actionSetWatchedFlag);
    popupMenu.add(actionRewriteNfo);
    popupMenu.add(actionRename2);
    popupMenu.add(actionRenamerPreview);
    popupMenu.add(actionMediaInformation2);
    popupMenu.add(actionExport);
    popupMenu.add(actionTrailerDownload);
    popupMenu.add(actionSearchSubtitle);
    popupMenu.add(actionDownloadSubtitle);
    popupMenu.addSeparator();
    popupMenu.add(actionSyncTrakt);
    popupMenu.add(actionSyncWatchedTrakt);
    popupMenu.add(actionSyncSelectedTrakt);
    popupMenu.addSeparator();
    popupMenu.add(actionClearImageCache);
    popupMenu.addSeparator();
    popupMenu.add(actionRemove2);
    popupMenu.add(actionDelete2);

    if (Globals.isDebug()) {
        JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$
        menuDebug.add(debugDumpMovie);
        menuDebug.addSeparator();
        menuDebug.add(new FakeTmmTaskAction("download", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("download", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10));
        popupMenu.add(menuDebug);
    }

    MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table);
    table.addMouseListener(mouseListener);
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getNewXmlItem() {
    JMenuItem item = new JMenuItem(NEW_XML_PROGRAM_MENU_NAME);
    addMnemonic(item, KeyEvent.VK_N);
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newXml();/*from   w w  w  .  j a  v  a  2 s  . c om*/
        }
    });

    return item;
}

From source file:com._17od.upm.gui.MainWindow.java

private JMenuBar createMenuBar() {

    JMenuBar menuBar = new JMenuBar();

    databaseMenu = new JMenu(Translator.translate("databaseMenu"));
    databaseMenu.setMnemonic(KeyEvent.VK_D);
    menuBar.add(databaseMenu);/*  ww w . ja v  a  2s  . com*/

    newDatabaseMenuItem = new JMenuItem(Translator.translate(NEW_DATABASE_TXT), KeyEvent.VK_N);
    newDatabaseMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    databaseMenu.add(newDatabaseMenuItem);
    newDatabaseMenuItem.addActionListener(this);
    newDatabaseMenuItem.setActionCommand(NEW_DATABASE_TXT);

    openDatabaseMenuItem = new JMenuItem(Translator.translate(OPEN_DATABASE_TXT), KeyEvent.VK_O);
    openDatabaseMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    databaseMenu.add(openDatabaseMenuItem);
    openDatabaseMenuItem.addActionListener(this);
    openDatabaseMenuItem.setActionCommand(OPEN_DATABASE_TXT);

    openDatabaseFromURLMenuItem = new JMenuItem(Translator.translate(OPEN_DATABASE_FROM_URL_TXT),
            KeyEvent.VK_L);
    openDatabaseFromURLMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    databaseMenu.add(openDatabaseFromURLMenuItem);
    openDatabaseFromURLMenuItem.addActionListener(this);
    openDatabaseFromURLMenuItem.setActionCommand(OPEN_DATABASE_FROM_URL_TXT);

    databaseMenu.addSeparator();

    syncWithRemoteDatabaseMenuItem = new JMenuItem(Translator.translate(SYNC_DATABASE_TXT), KeyEvent.VK_S);
    syncWithRemoteDatabaseMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    databaseMenu.add(syncWithRemoteDatabaseMenuItem);
    syncWithRemoteDatabaseMenuItem.addActionListener(this);
    syncWithRemoteDatabaseMenuItem.setEnabled(false);
    syncWithRemoteDatabaseMenuItem.setActionCommand(SYNC_DATABASE_TXT);

    changeMasterPasswordMenuItem = new JMenuItem(Translator.translate(CHANGE_MASTER_PASSWORD_TXT),
            KeyEvent.VK_G);
    changeMasterPasswordMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    databaseMenu.add(changeMasterPasswordMenuItem);
    changeMasterPasswordMenuItem.addActionListener(this);
    changeMasterPasswordMenuItem.setEnabled(false);
    changeMasterPasswordMenuItem.setActionCommand(CHANGE_MASTER_PASSWORD_TXT);

    databasePropertiesMenuItem = new JMenuItem(Translator.translate(DATABASE_PROPERTIES_TXT), KeyEvent.VK_I);
    databasePropertiesMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    databaseMenu.add(databasePropertiesMenuItem);
    databasePropertiesMenuItem.addActionListener(this);
    databasePropertiesMenuItem.setEnabled(false);
    databasePropertiesMenuItem.setActionCommand(DATABASE_PROPERTIES_TXT);

    databaseMenu.addSeparator();

    exportMenuItem = new JMenuItem(Translator.translate(EXPORT_TXT));
    databaseMenu.add(exportMenuItem);
    exportMenuItem.addActionListener(this);
    exportMenuItem.setEnabled(false);
    exportMenuItem.setActionCommand(EXPORT_TXT);

    importMenuItem = new JMenuItem(Translator.translate(IMPORT_TXT));
    databaseMenu.add(importMenuItem);
    importMenuItem.addActionListener(this);
    importMenuItem.setEnabled(false);
    importMenuItem.setActionCommand(IMPORT_TXT);

    accountMenu = new JMenu(Translator.translate("accountMenu"));
    accountMenu.setMnemonic(KeyEvent.VK_A);
    menuBar.add(accountMenu);

    addAccountMenuItem = new JMenuItem(Translator.translate(ADD_ACCOUNT_TXT), KeyEvent.VK_A);
    addAccountMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(addAccountMenuItem);
    addAccountMenuItem.addActionListener(this);
    addAccountMenuItem.setEnabled(false);
    addAccountMenuItem.setActionCommand(ADD_ACCOUNT_TXT);

    editAccountMenuItem = new JMenuItem(Translator.translate(EDIT_ACCOUNT_TXT), KeyEvent.VK_E);
    editAccountMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(editAccountMenuItem);
    editAccountMenuItem.addActionListener(this);
    editAccountMenuItem.setEnabled(false);
    editAccountMenuItem.setActionCommand(EDIT_ACCOUNT_TXT);

    deleteAccountMenuItem = new JMenuItem(Translator.translate(DELETE_ACCOUNT_TXT), KeyEvent.VK_D);
    deleteAccountMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(deleteAccountMenuItem);
    deleteAccountMenuItem.addActionListener(this);
    deleteAccountMenuItem.setEnabled(false);
    deleteAccountMenuItem.setActionCommand(DELETE_ACCOUNT_TXT);

    viewAccountMenuItem = new JMenuItem(Translator.translate(VIEW_ACCOUNT_TXT), KeyEvent.VK_V);
    viewAccountMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(viewAccountMenuItem);
    viewAccountMenuItem.addActionListener(this);
    viewAccountMenuItem.setEnabled(false);
    viewAccountMenuItem.setActionCommand(VIEW_ACCOUNT_TXT);

    copyUsernameMenuItem = new JMenuItem(Translator.translate(COPY_USERNAME_TXT), KeyEvent.VK_U);
    copyUsernameMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(copyUsernameMenuItem);
    copyUsernameMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyUsernameToClipboard();
        }
    });
    copyUsernameMenuItem.setEnabled(false);
    copyUsernameMenuItem.setActionCommand(COPY_USERNAME_TXT);

    copyPasswordMenuItem = new JMenuItem(Translator.translate(COPY_PASSWORD_TXT), KeyEvent.VK_P);
    copyPasswordMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(copyPasswordMenuItem);
    copyPasswordMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            copyPasswordToClipboard();
        }
    });

    copyPasswordMenuItem.setEnabled(false);
    copyPasswordMenuItem.setActionCommand(COPY_PASSWORD_TXT);

    launchURLMenuItem = new JMenuItem(Translator.translate(LAUNCH_URL_TXT), KeyEvent.VK_B);
    launchURLMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    accountMenu.add(launchURLMenuItem);
    launchURLMenuItem.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            AccountInformation accInfo = dbActions.getSelectedAccount();
            String uRl = accInfo.getUrl();

            // Check if the selected url is null or emty and inform the user
            // via JoptioPane message
            if ((uRl == null) || (uRl.length() == 0)) {
                JOptionPane.showMessageDialog(accountMenu.getParent().getParent(),
                        Translator.translate("EmptyUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Check if the selected url is a valid formated url(via
                // urlIsValid() method) and inform the user via JoptioPane
                // message
            } else if (!(urlIsValid(uRl))) {
                JOptionPane.showMessageDialog(accountMenu.getParent().getParent(),
                        Translator.translate("InvalidUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);

                // Call the method LaunchSelectedURL() using the selected
                // url as input
            } else {
                LaunchSelectedURL(uRl);

            }
        }
    });

    launchURLMenuItem.setEnabled(false);
    launchURLMenuItem.setActionCommand(LAUNCH_URL_TXT);

    exitMenuItem = new JMenuItem(Translator.translate(EXIT_TXT), KeyEvent.VK_X);
    exitMenuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    exitMenuItem.addActionListener(this);
    exitMenuItem.setActionCommand(EXIT_TXT);

    aboutMenuItem = new JMenuItem(Translator.translate(ABOUT_TXT), KeyEvent.VK_A);
    aboutMenuItem.addActionListener(this);
    aboutMenuItem.setActionCommand(ABOUT_TXT);

    // Because the MAC version of UPM will have a program item in the menu
    // bar then these items
    // only need to be added on non-mac platforms
    if (!PlatformSpecificCode.isMAC()) {
        databaseMenu.addSeparator();
        databaseMenu.add(exitMenuItem);

        helpMenu = new JMenu(Translator.translate("helpMenu"));
        helpMenu.setMnemonic(KeyEvent.VK_H);
        menuBar.add(helpMenu);

        helpMenu.add(aboutMenuItem);
    }

    return menuBar;

}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from ww  w  . j  a  v a  2  s  .  co  m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    panelMainArea = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    labelCellUnderMouse = new javax.swing.JLabel();
    labelZoomStatus = new javax.swing.JLabel();
    menuMain = new javax.swing.JMenuBar();
    menuFile = new javax.swing.JMenu();
    menuFileNew = new javax.swing.JMenuItem();
    menuItemFileOpen = new javax.swing.JMenuItem();
    menuFileSave = new javax.swing.JMenuItem();
    menuFileSaveAs = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JPopupMenu.Separator();
    menuFileExportAs = new javax.swing.JMenu();
    menuFileExportAsImage = new javax.swing.JMenuItem();
    menuFileExportAsSVG = new javax.swing.JMenuItem();
    menuFileExportAsXML = new javax.swing.JMenuItem();
    menuFileExportAsJavaConstants = new javax.swing.JMenuItem();
    jSeparator3 = new javax.swing.JPopupMenu.Separator();
    menuFileDocumentOptions = new javax.swing.JMenuItem();
    jSeparator4 = new javax.swing.JPopupMenu.Separator();
    menuFileExit = new javax.swing.JMenuItem();
    menuEdit = new javax.swing.JMenu();
    menuEditUndo = new javax.swing.JMenuItem();
    menuEditRedo = new javax.swing.JMenuItem();
    menuView = new javax.swing.JMenu();
    menuViewZoomIn = new javax.swing.JMenuItem();
    menuViewZoomOut = new javax.swing.JMenuItem();
    menuViewZoomReset = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JPopupMenu.Separator();
    menuViewBackImage = new javax.swing.JCheckBoxMenuItem();
    menuShowHexBorders = new javax.swing.JCheckBoxMenuItem();
    menuPlugins = new javax.swing.JMenu();
    menuWindow = new javax.swing.JMenu();
    menuWindowLayers = new javax.swing.JCheckBoxMenuItem();
    menuWindowTools = new javax.swing.JCheckBoxMenuItem();
    menuWindowOptions = new javax.swing.JCheckBoxMenuItem();
    menuLANDF = new javax.swing.JMenu();
    menuHelp = new javax.swing.JMenu();
    menuHelpAbout = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    setTitle("JHexed Map editor");
    setLocationByPlatform(true);
    setMinimumSize(new java.awt.Dimension(300, 300));
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    panelMainArea.setLayout(new java.awt.BorderLayout());

    jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    labelCellUnderMouse.setText("   ");

    labelZoomStatus.setText("   ");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(labelCellUnderMouse)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 705, Short.MAX_VALUE)
                    .addComponent(labelZoomStatus).addContainerGap()));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(labelCellUnderMouse).addComponent(labelZoomStatus))));

    panelMainArea.add(jPanel1, java.awt.BorderLayout.PAGE_END);

    getContentPane().add(panelMainArea, java.awt.BorderLayout.CENTER);

    menuFile.setText("File");
    menuFile.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileActionPerformed(evt);
        }
    });

    menuFileNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N,
            java.awt.event.InputEvent.CTRL_MASK));
    menuFileNew.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/new.png"))); // NOI18N
    menuFileNew.setText("New");
    menuFileNew.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileNewActionPerformed(evt);
        }
    });
    menuFile.add(menuFileNew);

    menuItemFileOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItemFileOpen.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/folder-open-image.png"))); // NOI18N
    menuItemFileOpen.setText("Open");
    menuItemFileOpen.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuItemFileOpenActionPerformed(evt);
        }
    });
    menuFile.add(menuItemFileOpen);

    menuFileSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.CTRL_MASK));
    menuFileSave.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/drive-download.png"))); // NOI18N
    menuFileSave.setText("Save");
    menuFileSave.setEnabled(false);
    menuFileSave.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileSaveActionPerformed(evt);
        }
    });
    menuFile.add(menuFileSave);

    menuFileSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    menuFileSaveAs.setText("Save As...");
    menuFileSaveAs.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileSaveAsActionPerformed(evt);
        }
    });
    menuFile.add(menuFileSaveAs);
    menuFile.add(jSeparator1);

    menuFileExportAs.setText("Export as...");

    menuFileExportAsImage.setText("PNG Image");
    menuFileExportAsImage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileExportAsImageActionPerformed(evt);
        }
    });
    menuFileExportAs.add(menuFileExportAsImage);

    menuFileExportAsSVG.setText("SVG Image");
    menuFileExportAsSVG.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileExportAsSVGActionPerformed(evt);
        }
    });
    menuFileExportAs.add(menuFileExportAsSVG);

    menuFileExportAsXML.setText("Xml file");
    menuFileExportAsXML.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileExportAsXMLActionPerformed(evt);
        }
    });
    menuFileExportAs.add(menuFileExportAsXML);

    menuFileExportAsJavaConstants.setText("Java constants");
    menuFileExportAsJavaConstants.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileExportAsJavaConstantsActionPerformed(evt);
        }
    });
    menuFileExportAs.add(menuFileExportAsJavaConstants);

    menuFile.add(menuFileExportAs);
    menuFile.add(jSeparator3);

    menuFileDocumentOptions.setText("Document options");
    menuFileDocumentOptions.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileDocumentOptionsActionPerformed(evt);
        }
    });
    menuFile.add(menuFileDocumentOptions);
    menuFile.add(jSeparator4);

    menuFileExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4,
            java.awt.event.InputEvent.ALT_MASK));
    menuFileExit.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/door-open-out.png"))); // NOI18N
    menuFileExit.setText("Exit");
    menuFileExit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuFileExitActionPerformed(evt);
        }
    });
    menuFile.add(menuFileExit);

    menuMain.add(menuFile);

    menuEdit.setText("Edit");

    menuEditUndo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z,
            java.awt.event.InputEvent.CTRL_MASK));
    menuEditUndo.setText("Undo");
    menuEditUndo.setEnabled(false);
    menuEditUndo.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuEditUndoActionPerformed(evt);
        }
    });
    menuEdit.add(menuEditUndo);

    menuEditRedo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X,
            java.awt.event.InputEvent.CTRL_MASK));
    menuEditRedo.setText("Redo");
    menuEditRedo.setEnabled(false);
    menuEditRedo.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuEditRedoActionPerformed(evt);
        }
    });
    menuEdit.add(menuEditRedo);

    menuMain.add(menuEdit);

    menuView.setText("View");

    menuViewZoomIn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.CTRL_MASK));
    menuViewZoomIn.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/magnifier-zoom-in.png"))); // NOI18N
    menuViewZoomIn.setText("Zoom In");
    menuViewZoomIn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuViewZoomInActionPerformed(evt);
        }
    });
    menuView.add(menuViewZoomIn);

    menuViewZoomOut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    menuViewZoomOut.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/magnifier-zoom-out.png"))); // NOI18N
    menuViewZoomOut.setText("Zoom Out");
    menuViewZoomOut.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuViewZoomOutActionPerformed(evt);
        }
    });
    menuView.add(menuViewZoomOut);

    menuViewZoomReset.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R,
            java.awt.event.InputEvent.CTRL_MASK));
    menuViewZoomReset.setIcon(new javax.swing.ImageIcon(
            getClass().getResource("/com/igormaznitsa/jhexed/swing/editor/icons/magnifier-zoom-actual.png"))); // NOI18N
    menuViewZoomReset.setText("Zoom Reset");
    menuViewZoomReset.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuViewZoomResetActionPerformed(evt);
        }
    });
    menuView.add(menuViewZoomReset);
    menuView.add(jSeparator2);

    menuViewBackImage.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
            java.awt.event.InputEvent.CTRL_MASK));
    menuViewBackImage.setSelected(true);
    menuViewBackImage.setText("Show back image");
    menuViewBackImage.setToolTipText("Show/Hide the background image");
    menuViewBackImage.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            menuViewBackImageStateChanged(evt);
        }
    });
    menuView.add(menuViewBackImage);

    menuShowHexBorders.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H,
            java.awt.event.InputEvent.CTRL_MASK));
    menuShowHexBorders.setSelected(true);
    menuShowHexBorders.setText("Show hex borders");
    menuShowHexBorders.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            menuShowHexBordersStateChanged(evt);
        }
    });
    menuView.add(menuShowHexBorders);

    menuMain.add(menuView);

    menuPlugins.setText("Plugins");
    menuMain.add(menuPlugins);

    menuWindow.setText("Window");

    menuWindowLayers.setSelected(true);
    menuWindowLayers.setText("Layers");
    menuWindowLayers.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuWindowLayersActionPerformed(evt);
        }
    });
    menuWindow.add(menuWindowLayers);

    menuWindowTools.setSelected(true);
    menuWindowTools.setText("Tools");
    menuWindowTools.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuWindowToolsActionPerformed(evt);
        }
    });
    menuWindow.add(menuWindowTools);

    menuWindowOptions.setSelected(true);
    menuWindowOptions.setText("Options");
    menuWindowOptions.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuWindowOptionsActionPerformed(evt);
        }
    });
    menuWindow.add(menuWindowOptions);

    menuMain.add(menuWindow);

    menuLANDF.setText("Look&Feel");
    menuMain.add(menuLANDF);

    menuHelp.setText("Help");

    menuHelpAbout.setText("About");
    menuHelpAbout.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuHelpAboutActionPerformed(evt);
        }
    });
    menuHelp.add(menuHelpAbout);

    menuMain.add(menuHelp);

    setJMenuBar(menuMain);

    pack();
}

From source file:lejos.pc.charting.LogChartFrame.java

/** All the setup of components, etc. What's scary is Swing is a "lightweight" GUI framework...
 * @throws Exception/*w ww. jav a 2  s. c  o  m*/
 */
private void jbInit() throws Exception {
    this.setJMenuBar(menuBar);
    this.setSize(new Dimension(819, 613));
    this.setMinimumSize(new Dimension(819, 613));
    this.setTitle("NXT Charting Logger");
    this.setEnabled(true);
    // enforce minimum window size
    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            JFrame theFrame = (JFrame) e.getSource();
            Dimension d1 = theFrame.getMinimumSize();
            Dimension d2 = theFrame.getSize();
            boolean enforce = false;
            if (theFrame.getWidth() < d1.getWidth()) {
                d2.setSize(d1.getWidth(), d2.getHeight());
                enforce = true;
            }
            if (theFrame.getHeight() < d1.getHeight()) {
                d2.setSize(d2.getWidth(), d1.getHeight());
                enforce = true;
            }
            if (enforce)
                theFrame.setSize(d2);
        }
    });

    this.getContentPane().setLayout(gridBagLayout1);
    MenuActionListener menuItemActionListener = new MenuActionListener();
    MenuEventListener menuListener = new MenuEventListener();

    menu = new JMenu("Edit");
    menu.setMnemonic(KeyEvent.VK_E);
    menuBar.add(menu);
    menuItem = new JMenuItem("Copy Chart Image", KeyEvent.VK_I);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("Copy Data Log", KeyEvent.VK_D);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);

    menu = new JMenu("View");
    menu.setMnemonic(KeyEvent.VK_V);
    menu.setActionCommand("VIEW_MENU");
    menu.addMenuListener(menuListener);
    menuBar.add(menu);
    menuItem = new JMenuItem("Expand Chart", KeyEvent.VK_F);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("Chart in New Window", KeyEvent.VK_N);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);

    menu = new JMenu("Help");
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);
    menuItem = new JMenuItem("Chart controls", KeyEvent.VK_C);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("Generate sample data", KeyEvent.VK_G);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("About", KeyEvent.VK_A);
    menuItem.addActionListener(menuItemActionListener);
    jTabbedPane1.setPreferredSize(new Dimension(621, 199));
    jTabbedPane1.setMinimumSize(new Dimension(621, 199));
    menu.add(menuItem);

    jButtonConnect.setText("Connect");
    jButtonConnect.setBounds(new Rectangle(25, 65, 115, 25));
    jButtonConnect.setToolTipText("Connect/disconnect toggle");
    jButtonConnect.setMnemonic('C');
    jButtonConnect.setSelected(true);
    jButtonConnect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            jButtonConnect_actionPerformed(e);
        }
    });
    UIPanel.setSize(new Dimension(820, 200));
    UIPanel.setLayout(null);
    UIPanel.setPreferredSize(new Dimension(300, 200));
    UIPanel.setMinimumSize(new Dimension(300, 200));
    UIPanel.setBounds(new Rectangle(0, 350, 820, 200));
    UIPanel.setMaximumSize(new Dimension(300, 32767));
    connectionPanel.setBounds(new Rectangle(10, 10, 175, 100));
    connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection"));
    connectionPanel.setLayout(null);
    connectionPanel.setFont(new Font("Tahoma", 0, 11));

    jLabel1logfilename.setText("Log File:");
    jLabel1logfilename.setBounds(new Rectangle(10, 125, 165, 20));
    jLabel1logfilename.setHorizontalTextPosition(SwingConstants.RIGHT);
    jLabel1logfilename.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel1logfilename.setToolTipText("Specify the name of your log file here");

    jTextFieldNXTName.setBounds(new Rectangle(5, 40, 165, 20));
    jTextFieldNXTName.setToolTipText(
            "The name or Address of the NXT. Leave empty and the first one found will be used.");

    jTextFieldNXTName.requestFocus();

    jTextAreaStatus.setLineWrap(true);
    jTextAreaStatus.setFont(new Font("Tahoma", 0, 11));
    jTextAreaStatus.setWrapStyleWord(true);
    jTextAreaStatus.setBackground(SystemColor.window);

    dataLogTextArea.setLineWrap(false);
    dataLogTextArea.setFont(new Font("Tahoma", 0, 11));
    dataLogTextArea.setBackground(SystemColor.window);

    FQPathTextArea.setBounds(new Rectangle(5, 170, 185, 40));
    FQPathTextArea.setLineWrap(true);
    FQPathTextArea.setText(getCanonicalName(new File(".", "")));
    FQPathTextArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    FQPathTextArea.setRows(2);

    FQPathTextArea.setFont(new Font("Tahoma", 0, 9));
    FQPathTextArea.setOpaque(false);
    FQPathTextArea.setEditable(false);

    selectFolderButton.setText("Folder...");
    selectFolderButton.setBounds(new Rectangle(120, 125, 70, 20));
    selectFolderButton.setMargin(new Insets(1, 1, 1, 1));
    selectFolderButton.setFocusable(false);
    selectFolderButton.setMnemonic('F');
    selectFolderButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            selectFolderButton_actionPerformed(e);
        }
    });

    // domain display limits GUI
    chartOptionsPanel.setLayout(null);
    chartDomLimitsPanel.setBounds(new Rectangle(5, 35, 180, 135));
    chartDomLimitsPanel.setLayout(gridLayout1);
    chartDomLimitsPanel.setBorder(BorderFactory.createTitledBorder("Domain Display Limiting"));
    domainDisplayLimitSlider.setEnabled(false);
    domainDisplayLimitSlider.setMaximum(MAXDOMAIN_DATAPOINT_LIMIT);
    domainDisplayLimitSlider.setMinimum(MINDOMAIN_LIMIT);
    domainDisplayLimitSlider.setValue(MAXDOMAIN_DATAPOINT_LIMIT);
    domainDisplayLimitSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            domainDisplayLimitSlider_stateChanged(e);
        }
    });
    useTimeRadioButton.setText("By Time");
    useTimeRadioButton.setEnabled(false);
    useTimeRadioButton.setMnemonic('I');
    useTimeRadioButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            domainDisplayLimitRadioButton_actionPerformed(e);
        }
    });
    useDataPointsRadioButton.setText("By Data Points");
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(useTimeRadioButton);
    bg1.add(useDataPointsRadioButton);
    useDataPointsRadioButton.setSelected(true);
    useDataPointsRadioButton.setEnabled(false);
    useDataPointsRadioButton.setMnemonic('P');
    useDataPointsRadioButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            domainDisplayLimitRadioButton_actionPerformed(e);
        }
    });
    datasetLimitEnableCheckBox.setText("Enable");
    datasetLimitEnableCheckBox.setRolloverEnabled(true);
    datasetLimitEnableCheckBox.setMnemonic('A');
    datasetLimitEnableCheckBox.setToolTipText("Enable Domain Clipping");
    datasetLimitEnableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            datasetLimitEnableCheckBox_actionPerformed(e);
        }
    });
    domainLimitLabel.setText(String.format("%1$,d datapoints", MAXDOMAIN_DATAPOINT_LIMIT).toString());
    domainLimitLabel.setEnabled(false);
    gridLayout1.setRows(5);
    gridLayout1.setColumns(1);

    jLabel1.setText("Chart Title:");
    jLabel1.setBounds(new Rectangle(200, 10, 85, 20));
    jLabel1.setPreferredSize(new Dimension(115, 14));
    jLabel2.setText("Range Axis 1 Label:");
    jLabel2.setBounds(new Rectangle(200, 35, 115, 20));
    jLabel2.setSize(new Dimension(115, 20));
    jLabel3.setText("Range Axis 2 Label:");
    jLabel3.setBounds(new Rectangle(200, 60, 115, 20));
    jLabel3.setSize(new Dimension(115, 20));
    jLabel4.setText("Range Axis 3 Label:");
    jLabel4.setBounds(new Rectangle(200, 85, 115, 20));
    jLabel4.setSize(new Dimension(115, 20));
    jLabel6.setText("Range Axis 4 Label:");
    jLabel6.setBounds(new Rectangle(200, 110, 115, 20));
    jLabel6.setSize(new Dimension(115, 20));
    titleLabelChangeNotifier notifier = new titleLabelChangeNotifier();
    chartTitleTextField.setBounds(new Rectangle(315, 10, 290, 20));
    chartTitleTextField.getDocument().addDocumentListener(notifier);
    axis1LabelTextField.setBounds(new Rectangle(315, 35, 290, 20));
    axis1LabelTextField.getDocument().addDocumentListener(notifier);
    axis2LabelTextField.setBounds(new Rectangle(315, 60, 290, 20));
    axis2LabelTextField.getDocument().addDocumentListener(notifier);
    axis3LabelTextField.setBounds(new Rectangle(315, 85, 290, 20));
    axis3LabelTextField.getDocument().addDocumentListener(notifier);
    axis4LabelTextField.setBounds(new Rectangle(315, 110, 290, 20));
    showCommentsCheckBox.setText("Show Comment Markers");
    showCommentsCheckBox.setBounds(new Rectangle(200, 140, 185, 25));
    showCommentsCheckBox.setToolTipText("Show/Hide any comment markers on the chart");
    showCommentsCheckBox.setRolloverEnabled(true);
    showCommentsCheckBox.setSelected(true);
    showCommentsCheckBox.setMnemonic('M');
    showCommentsCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            customChartPanel.setCommentsVisible(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    scrollDomainCheckBox.setText("Scroll Domain");
    scrollDomainCheckBox.setBounds(new Rectangle(10, 5, 175, 20));
    scrollDomainCheckBox.setSize(new Dimension(175, 25));
    scrollDomainCheckBox.setSelected(true);
    scrollDomainCheckBox.setMnemonic('O');
    scrollDomainCheckBox.setToolTipText("Checked to scroll domain as new data is received");
    scrollDomainCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scrollDomainCheckBox_actionPerformed(e);
        }
    });
    axis4LabelTextField.getDocument().addDocumentListener(notifier);

    logFileTextField.setBounds(new Rectangle(10, 145, 180, 20));
    logFileTextField.setText("NXTData.txt");
    logFileTextField.setPreferredSize(new Dimension(180, 20));
    logFileTextField.setToolTipText("File name. Leave empty to not log to file.");
    statusScrollPane.setOpaque(false);
    dataLogScrollPane.setOpaque(false);

    customChartPanel.setMinimumSize(new Dimension(400, 300));
    customChartPanel.setPreferredSize(new Dimension(812, 400));

    jLabel5.setText("NXT Name/Address:");
    jLabel5.setBounds(new Rectangle(5, 20, 160, 20));
    jLabel5.setToolTipText(jTextFieldNXTName.getToolTipText());
    jLabel5.setHorizontalTextPosition(SwingConstants.RIGHT);
    jLabel5.setHorizontalAlignment(SwingConstants.LEFT);

    connectionPanel.add(jTextFieldNXTName, null);
    connectionPanel.add(jButtonConnect, null);
    connectionPanel.add(jLabel5, null);
    dataLogScrollPane.setViewportView(dataLogTextArea);
    jTabbedPane1.addTab("Data Log", dataLogScrollPane);
    statusScrollPane.setViewportView(jTextAreaStatus);
    jTabbedPane1.addTab("Status", statusScrollPane);
    jTabbedPane1.addTab("Chart", chartOptionsPanel);
    chartDomLimitsPanel.add(datasetLimitEnableCheckBox, null);
    chartDomLimitsPanel.add(useDataPointsRadioButton, null);
    chartDomLimitsPanel.add(useTimeRadioButton, null);
    chartDomLimitsPanel.add(domainDisplayLimitSlider, null);
    chartDomLimitsPanel.add(domainLimitLabel, null);
    chartOptionsPanel.add(scrollDomainCheckBox, null);
    chartOptionsPanel.add(showCommentsCheckBox, null);
    chartOptionsPanel.add(axis4LabelTextField, null);
    chartOptionsPanel.add(axis3LabelTextField, null);
    chartOptionsPanel.add(axis2LabelTextField, null);
    chartOptionsPanel.add(axis1LabelTextField, null);
    chartOptionsPanel.add(chartTitleTextField, null);
    chartOptionsPanel.add(jLabel6, null);
    chartOptionsPanel.add(jLabel4, null);
    chartOptionsPanel.add(jLabel3, null);
    chartOptionsPanel.add(jLabel2, null);
    chartOptionsPanel.add(jLabel1, null);
    chartOptionsPanel.add(chartDomLimitsPanel, null);

    tglbtnpauseplay = new JToggleButton("");
    tglbtnpauseplay.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (lpm == null)
                return;
            boolean doPause = false;
            if (e.getStateChange() == ItemEvent.SELECTED) {
                doPause = true;
            }
            lpm.setReaderPaused(doPause);
        }
    });
    //        tglbtnpauseplay.addChangeListener(new ChangeListener() {
    //           public void stateChanged(ChangeEvent e) {
    //              System.out.println(e.toString());
    //              //lpm.setReaderPaused(doPause)
    //           }
    //        });
    tglbtnpauseplay
            .setSelectedIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/play.png")));
    tglbtnpauseplay.setIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/pause.png")));
    tglbtnpauseplay.setBounds(571, 135, 30, 30);
    chartOptionsPanel.add(tglbtnpauseplay);

    jTabbedPane1.setToolTipTextAt(0, "The tab-delimited log of the data sent from the NXT");
    jTabbedPane1.setToolTipTextAt(1, "Status output");
    jTabbedPane1.setToolTipTextAt(2, "Chart options");
    jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_D);
    jTabbedPane1.setMnemonicAt(1, KeyEvent.VK_S);
    jTabbedPane1.setMnemonicAt(2, KeyEvent.VK_T);
    this.getContentPane().add(customChartPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0,
            GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    this.getContentPane().add(UIPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -107, 0));

    this.getContentPane().add(jTabbedPane1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
            GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    UIPanel.add(connectionPanel, null);
    UIPanel.add(selectFolderButton, null);
    UIPanel.add(logFileTextField, null);
    UIPanel.add(jLabel1logfilename, null);
    UIPanel.add(FQPathTextArea, null);
    ActionListener taskPerformer = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String theData = null;
            for (;;) {
                theData = LogChartFrame.this.logDataQueue.poll();
                if (theData == null)
                    break;
                try {
                    dataLogTextArea.getDocument().insertString(dataLogTextArea.getDocument().getLength(),
                            theData, null);
                } catch (BadLocationException e) {
                    System.out.print(
                            "BadLocationException in datalog textarea updater thread:" + e.toString() + "\n");
                }
            }
        }
    };
    this.updateLogTextAreaTimer = new Timer(1000, taskPerformer);
    this.updateLogTextAreaTimer.start();
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.FormPane.java

/**
 * Creates the proper UI component for the Mapping item.
 * @param dbFieldType the field type//from w  w w . java  2s.  c o m
 * @param caption the caption
 * @param fieldName the name of the field
 * @param dataFieldLength the length of the definition for that field
 * @param fieldType the field type
 * @return a UI component for editing
 */
protected JComponent createUIComp(final Class<?> dbFieldTypeArg, final String caption, final String fieldName,
        final Short fieldType, final Short fieldLength, final short columns, final short rows,
        final WorkbenchTemplateMappingItem wbtmi) {
    short uiType = WorkbenchTemplateMappingItem.UNKNOWN;
    //System.out.println(wbtmi.getCaption()+" "+wbtmi.getDataType()+" "+wbtmi.getFieldLength());
    Class<?> dbFieldType = dbFieldTypeArg;
    if (dbFieldType == null) {
        // if we can't find a class for the field (i.e. Genus Species, or other 'fake' fields), we say it's a string
        dbFieldType = String.class;
    }

    JComponent comp;
    Component focusComp;

    // handle dates
    if (dbFieldType.equals(Calendar.class) || dbFieldType.equals(Date.class)) {
        //ValFormattedTextField txt = new ValFormattedTextField("Date"); 
        //txt.setColumns(columns == -1 ? DEFAULT_TEXTFIELD_COLS : columns);
        ValTextField txt = new ValTextField(columns);
        txt.getDocument().addDocumentListener(docListener);
        comp = txt;
        focusComp = comp;
        uiType = WorkbenchTemplateMappingItem.TEXTFIELD_DATE;
    }
    //        else if (dbFieldType.equals(Boolean.class)) // strings
    //        {
    //            ValCheckBox checkBox = new ValCheckBox(caption, false, false);
    //            checkBox.addChangeListener(changeListener);
    //            comp      = checkBox;
    //            focusComp = comp;
    //            uiType = WorkbenchTemplateMappingItem.CHECKBOX;
    //        }
    else if (useComboBox(wbtmi)) {
        //ValComboBox comboBox = new ValComboBox(getValues(wbtmi), true);

        final JComboBox comboBox = new JComboBox(getValues(wbtmi));
        comboBox.setName("Form Combo");
        comboBox.setEditable(true);
        comboBox.addActionListener(new ActionListener() {

            /* (non-Javadoc)
             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
             */
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (arg0.getSource() == comboBox) {
                    //System.out.println("ComboBox Action!" + ((JComboBox )arg0.getSource()).getName());
                    stateChange();
                }
            }

        });
        //           comboBox.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
        //
        //            /* (non-Javadoc)
        //             * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
        //             */
        //            @Override
        //            public void focusGained(FocusEvent arg0) {
        //               System.out.println("FOCUS GAINED");
        //               
        //            }
        //
        //            /* (non-Javadoc)
        //             * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
        //             */
        //            @Override
        //            public void focusLost(FocusEvent arg0) {
        //               System.out.println("FOCUS LOST");
        //               
        //            }
        //              
        //           });
        comp = comboBox;
        focusComp = comp;
        uiType = WorkbenchTemplateMappingItem.COMBOBOX;
    } else if (useTextField(fieldName, fieldType, fieldLength)) {
        ValTextField txt = new ValTextField(columns);
        txt.getDocument().addDocumentListener(docListener);
        txt.setInputVerifier(new LengthInputVerifier(caption, fieldLength));
        comp = txt;
        focusComp = comp;
        uiType = WorkbenchTemplateMappingItem.TEXTFIELD;

    } else {
        JScrollPane taScrollPane = createTextArea(columns, rows);
        ((JTextArea) taScrollPane.getViewport().getView())
                .setInputVerifier(new LengthInputVerifier(caption, fieldLength));
        comp = taScrollPane;
        focusComp = taScrollPane.getViewport().getView();
        uiType = WorkbenchTemplateMappingItem.TEXTAREA;
    }

    wbtmi.setFieldType(uiType);

    focusComp.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            selectControl(e.getSource());
        }

        public void focusLost(FocusEvent e) {
            //stateChange();
        }
    });

    comp.setEnabled(!readOnly);
    focusComp.setEnabled(!readOnly);

    comp.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (!readOnly) {
                if ((e.isControlDown() || e.isMetaDown()) && e.getKeyCode() == KeyEvent.VK_N) {
                    workbenchPane.addRowAfter();
                }
            }
            super.keyTyped(e);
        }

    });
    return comp;
}

From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java

/**
 * Builds the menu.//from   w ww .jav  a  2 s  . c o  m
 */
private void buildMenu() {
    menu.setMnemonic(KeyEvent.VK_V);

    // menu items
    JMenuItem menuItem = menu.add(actionUpdateDatasources2);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menu.addSeparator();

    JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
    menuScrape.setMnemonic(KeyEvent.VK_S);
    menuItem = menuScrape.add(actionScrape2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeSelected);
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeNewItems);
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menu.add(menuScrape);

    JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$
    menuEdit.setMnemonic(KeyEvent.VK_E);
    menuItem = menuEdit.add(actionEdit2);
    menuItem.setMnemonic(KeyEvent.VK_E);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionBatchEdit);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionSetWatchedFlag);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionChangeSeasonPoster2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuEdit.add(actionChangeToDvdOrder);
    menuEdit.add(actionChangeToAiredOrder);

    menu.add(menuEdit);
    menu.add(actionRewriteTvShowNfo);
    menu.add(actionRewriteTvShowEpisodeNfo);

    menuItem = menu.add(actionRename);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionMediaInformation2);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionExport);
    menuItem.setMnemonic(KeyEvent.VK_X);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionClearImageCache);
    menuItem.setMnemonic(KeyEvent.VK_C);

    menu.addSeparator();
    menuItem = menu.add(actionRemove2);
    menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE));
    menuItem = menu.add(actionDelete2);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));

    menu.addSeparator();
    menuItem = menu.add(actionSyncTrakt);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem = menu.add(actionSyncWatchedTrakt);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem = menu.add(actionSyncSelectedTrakt);

    // popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(actionScrape2);
    popupMenu.add(actionScrapeSelected);
    popupMenu.add(actionScrapeEpisodes);
    popupMenu.add(actionScrapeEpisodes2);
    popupMenu.add(actionScrapeNewItems);
    // popupMenu.add(actionScrapeMetadataSelected);
    popupMenu.addSeparator();
    popupMenu.add(actionUpdateTvShow);
    popupMenu.addSeparator();
    popupMenu.add(actionEdit2);
    popupMenu.add(actionChangeSeasonPoster2);
    popupMenu.add(actionBatchEdit);
    popupMenu.add(actionSetWatchedFlag);
    popupMenu.add(actionChangeToDvdOrder);
    popupMenu.add(actionChangeToAiredOrder);
    popupMenu.add(actionRewriteTvShowNfo);
    popupMenu.add(actionRewriteTvShowEpisodeNfo);
    // popupMenu.add(actionBatchEdit);
    popupMenu.add(actionRename);
    popupMenu.add(actionMediaInformation2);
    popupMenu.add(actionExport);
    popupMenu.add(actionClearImageCache);
    popupMenu.addSeparator();
    popupMenu.add(actionDownloadSubtitles);
    popupMenu.add(actionSearchAndDownloadSubtitles);
    popupMenu.addSeparator();
    popupMenu.add(actionSyncTrakt);
    popupMenu.add(actionSyncWatchedTrakt);
    popupMenu.add(actionSyncSelectedTrakt);
    popupMenu.addSeparator();
    popupMenu.add(actionRemove2);
    popupMenu.add(actionDelete2);
    popupMenu.addSeparator();
    popupMenu.add(new ExpandAllAction());
    popupMenu.add(new CollapseAllAction());

    if (Globals.isDebug()) {
        JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$
        menuDebug.add(debugDumpShow);
        popupMenu.addSeparator();
        popupMenu.add(menuDebug);
    }

    MouseListener popupListener = new TreePopupListener(popupMenu, tree);
    tree.addMouseListener(popupListener);
}

From source file:edu.harvard.mcz.imagecapture.PositionTemplateEditor.java

/**
 * This method initializes jMenuItem   //from ww  w  .  jav a 2 s.c om
 *    
 * @return javax.swing.JMenuItem   
 */
private JMenuItem getJMenuItemCreateTemplate() {
    if (jMenuItem == null) {
        jMenuItem = new JMenuItem();
        jMenuItem.setText("Create New Template From Image");
        jMenuItem.setMnemonic(KeyEvent.VK_N);
        jMenuItem.setEnabled(true);
        jMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {
                template = new PositionTemplate(true);
                template.setImageSize(imagePanelForDrawing.getImageSize());
                jTextField2.setText(
                        "Width=" + template.getImageSize().width + " Height=" + template.getImageSize().height);
                setButtonTexts();
                drawLayers();
                jButtonSave.setEnabled(template.isEditable());
                controlBarcode.setEnabled(template.isEditable());
                controlText.setEnabled(template.isEditable());
                controlLabel.setEnabled(template.isEditable());
                controlUTLabels.setEnabled(template.isEditable());
                controlSpecimen.setEnabled(template.isEditable());
                controlUTBarcode.setEnabled(template.isEditable());
                drawLayers();
            }
        });
    }
    return jMenuItem;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java

/**
 * Constructs the pane for the spreadsheet.
 * /*from  www  .  j av a 2 s  .  co  m*/
 * @param name the name of the pane
 * @param task the owning task
 * @param workbench the workbench to be edited
 * @param showImageView shows image window when first showing the window
 */
public WorkbenchPaneSS(final String name, final Taskable task, final Workbench workbenchArg,
        final boolean showImageView, final boolean isReadOnly) throws Exception {
    super(name, task);

    removeAll();

    if (workbenchArg == null) {
        return;
    }
    this.workbench = workbenchArg;

    this.isReadOnly = isReadOnly;

    headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    Collections.sort(headers);

    boolean hasOneOrMoreImages = false;
    // pre load all the data
    for (WorkbenchRow wbRow : workbench.getWorkbenchRows()) {
        for (WorkbenchDataItem wbdi : wbRow.getWorkbenchDataItems()) {
            wbdi.getCellData();
        }

        if (wbRow.getWorkbenchRowImages() != null && wbRow.getWorkbenchRowImages().size() > 0) {
            hasOneOrMoreImages = true;
        }
    }

    model = new GridTableModel(this);
    spreadSheet = new WorkbenchSpreadSheet(model, this);
    spreadSheet.setReadOnly(isReadOnly);
    model.setSpreadSheet(spreadSheet);

    Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
    GridCellHighlighter hl = new GridCellHighlighter(
            new GridCellPredicate(GridCellPredicate.AnyPredicate, null));
    Short[] errs = { WorkbenchDataItem.VAL_ERROR, WorkbenchDataItem.VAL_ERROR_EDIT };
    ColorHighlighter errColorHighlighter = new ColorHighlighter(
            new GridCellPredicate(GridCellPredicate.ValidationPredicate, errs),
            CellRenderingAttributes.errorBackground, null);
    Short[] newdata = { WorkbenchDataItem.VAL_NEW_DATA };
    ColorHighlighter noDataHighlighter = new ColorHighlighter(
            new GridCellPredicate(GridCellPredicate.MatchingPredicate, newdata),
            CellRenderingAttributes.newDataBackground, null);
    Short[] multimatch = { WorkbenchDataItem.VAL_MULTIPLE_MATCH };
    ColorHighlighter multiMatchHighlighter = new ColorHighlighter(
            new GridCellPredicate(GridCellPredicate.MatchingPredicate, multimatch),
            CellRenderingAttributes.multipleMatchBackground, null);

    spreadSheet.setHighlighters(simpleStriping, hl, errColorHighlighter, noDataHighlighter,
            multiMatchHighlighter);

    //add key mappings for cut, copy, paste
    //XXX Note: these are shortcuts directly to the SpreadSheet cut,copy,paste methods, NOT to the Specify edit menu.
    addRecordKeyMappings(spreadSheet, KeyEvent.VK_C, "Copy", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    spreadSheet.cutOrCopy(false);
                }
            });
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    addRecordKeyMappings(spreadSheet, KeyEvent.VK_X, "Cut", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    spreadSheet.cutOrCopy(true);
                }
            });
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    addRecordKeyMappings(spreadSheet, KeyEvent.VK_V, "Paste", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    spreadSheet.paste();
                }
            });
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    findPanel = spreadSheet.getFindReplacePanel();
    UIRegistry.getLaunchFindReplaceAction().setSearchReplacePanel(findPanel);

    spreadSheet.setShowGrid(true);
    JTableHeader header = spreadSheet.getTableHeader();
    header.addMouseListener(new ColumnHeaderListener());
    header.setReorderingAllowed(false); // Turn Off column dragging

    // Put the model in image mode, and never change it.
    // Now we're showing/hiding the image column using JXTable's column hiding features.
    model.setInImageMode(true);
    int imageColIndex = model.getColumnCount() - 1;
    imageColExt = spreadSheet.getColumnExt(imageColIndex);
    imageColExt.setVisible(false);

    int sgrColIndex = model.getSgrHeading().getViewOrder();
    sgrColExt = spreadSheet.getColumnExt(sgrColIndex);
    sgrColExt.setComparator(((WorkbenchSpreadSheet) spreadSheet).new NumericColumnComparator());

    int cmpIdx = 0;
    for (Comparator<String> cmp : ((WorkbenchSpreadSheet) spreadSheet).getComparators()) {
        if (cmp != null) {
            spreadSheet.getColumnExt(cmpIdx++).setComparator(cmp);
        }
    }

    // Start off with the SGR score column hidden
    showHideSgrCol(false);

    model.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            setChanged(true);
        }
    });

    spreadSheet.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            UIRegistry.enableCutCopyPaste(true);
            UIRegistry.enableFind(findPanel, true);
        }

        @Override
        public void focusLost(FocusEvent e) {
            UIRegistry.enableCutCopyPaste(true);
            UIRegistry.enableFind(findPanel, true);
        }
    });

    if (isReadOnly) {
        saveBtn = null;
    } else {
        saveBtn = createButton(getResourceString("SAVE"));
        saveBtn.setToolTipText(
                String.format(getResourceString("WB_SAVE_DATASET_TT"), new Object[] { workbench.getName() }));
        saveBtn.setEnabled(false);
        saveBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                UsageTracker.incrUsageCount("WB.SaveDataSet");

                UIRegistry.writeSimpleGlassPaneMsg(
                        String.format(getResourceString("WB_SAVING"), new Object[] { workbench.getName() }),
                        WorkbenchTask.GLASSPANE_FONT_SIZE);
                UIRegistry.getStatusBar().setIndeterminate(workbench.getName(), true);
                final SwingWorker worker = new SwingWorker() {
                    @SuppressWarnings("synthetic-access")
                    @Override
                    public Object construct() {
                        try {
                            saveObject();

                        } catch (Exception ex) {
                            UsageTracker.incrHandledUsageCount();
                            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchPaneSS.class,
                                    ex);
                            log.error(ex);
                            return ex;
                        }
                        return null;
                    }

                    // Runs on the event-dispatching thread.
                    @Override
                    public void finished() {
                        Object retVal = get();
                        if (retVal != null && retVal instanceof Exception) {
                            Exception ex = (Exception) retVal;
                            UIRegistry.getStatusBar().setErrorMessage(getResourceString("WB_ERROR_SAVING"), ex);
                        }

                        UIRegistry.clearSimpleGlassPaneMsg();
                        UIRegistry.getStatusBar().setProgressDone(workbench.getName());
                    }
                };
                worker.start();

            }
        });
    }

    Action delAction = addRecordKeyMappings(spreadSheet, KeyEvent.VK_F3, "DelRow", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            if (validationWorkerQueue.peek() == null) {
                deleteRows();
            }
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    if (isReadOnly) {
        deleteRowsBtn = null;
    } else {
        deleteRowsBtn = createIconBtn("DelRec", "WB_DELETE_ROW", delAction);
        selectionSensitiveButtons.add(deleteRowsBtn);
        spreadSheet.setDeleteAction(delAction);
    }

    //XXX Using the wb ID in the prefname to do pref setting per wb, may result in a bloated prefs file?? 
    doIncrementalValidation = AppPreferences.getLocalPrefs()
            .getBoolean(wbAutoValidatePrefName + "." + workbench.getId(), true);
    doIncrementalMatching = AppPreferences.getLocalPrefs()
            .getBoolean(wbAutoMatchPrefName + "." + workbench.getId(), false);

    if (isReadOnly) {
        clearCellsBtn = null;
    } else {
        clearCellsBtn = createIconBtn("Eraser", "WB_CLEAR_CELLS", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                spreadSheet.clearSorter();

                if (spreadSheet.getCellEditor() != null) {
                    spreadSheet.getCellEditor().stopCellEditing();
                }
                int[] rows = spreadSheet.getSelectedRowModelIndexes();
                int[] cols = spreadSheet.getSelectedColumnModelIndexes();
                model.clearCells(rows, cols);
            }
        });
        selectionSensitiveButtons.add(clearCellsBtn);
    }

    Action addAction = addRecordKeyMappings(spreadSheet, KeyEvent.VK_N, "AddRow", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            if (workbench.getWorkbenchRows().size() < WorkbenchTask.MAX_ROWS) {
                if (validationWorkerQueue.peek() == null) {
                    addRowAfter();
                }
            }
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    if (isReadOnly) {
        addRowsBtn = null;
    } else {
        addRowsBtn = createIconBtn("AddRec", "WB_ADD_ROW", addAction);
        addRowsBtn.setEnabled(true);
        addAction.setEnabled(true);
    }

    if (isReadOnly) {
        carryForwardBtn = null;
    } else {
        carryForwardBtn = createIconBtn("CarryForward20x20", IconManager.IconSize.NonStd, "WB_CARRYFORWARD",
                false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        UsageTracker.getUsageCount("WBCarryForward");

                        configCarryFoward();
                    }
                });
        carryForwardBtn.setEnabled(true);
    }

    toggleImageFrameBtn = createIconBtn("CardImage", IconManager.IconSize.NonStd, "WB_SHOW_IMG_WIN", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    toggleImageFrameVisible();
                }
            });
    toggleImageFrameBtn.setEnabled(true);

    importImagesBtn = createIconBtn("CardImage", IconManager.IconSize.NonStd, "WB_SHOW_IMG_WIN", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    toggleImportImageFrameVisible();
                }
            });
    importImagesBtn.setEnabled(true);

    /*showMapBtn = createIconBtn("ShowMap", IconManager.IconSize.NonStd, "WB_SHOW_MAP", false, new ActionListener()
    {
    public void actionPerformed(ActionEvent ae)
    {
        showMapOfSelectedRecords();
    }
    });*/
    // enable or disable along with Google Earth and Geo Ref Convert buttons

    if (isReadOnly) {
        exportKmlBtn = null;
    } else {
        exportKmlBtn = createIconBtn("GoogleEarth", IconManager.IconSize.NonStd, "WB_SHOW_IN_GOOGLE_EARTH",
                false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                showRecordsInGoogleEarth();
                            }
                        });
                    }
                });
    }

    // 

    readRegisteries();

    // enable or disable along with Show Map and Geo Ref Convert buttons

    if (isReadOnly) {
        geoRefToolBtn = null;
    } else {
        AppPreferences remotePrefs = AppPreferences.getRemote();
        final String tool = remotePrefs.get("georef_tool", "geolocate");
        String iconName = "GEOLocate20"; //tool.equalsIgnoreCase("geolocate") ? "GeoLocate" : "BioGeoMancer";
        String toolTip = tool.equalsIgnoreCase("geolocate") ? "WB_DO_GEOLOCATE_LOOKUP"
                : "WB_DO_BIOGEOMANCER_LOOKUP";
        geoRefToolBtn = createIconBtn(iconName, IconManager.IconSize.NonStd, toolTip, false,
                new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        spreadSheet.clearSorter();

                        if (tool.equalsIgnoreCase("geolocate")) {
                            doGeoRef(new edu.ku.brc.services.geolocate.prototype.GeoCoordGeoLocateProvider(),
                                    "WB.GeoLocateRows");
                        } else {
                            doGeoRef(new GeoCoordBGMProvider(), "WB.BioGeomancerRows");
                        }
                    }
                });
        // only enable it if the workbench has the proper columns in it
        String[] missingColumnsForBG = getMissingButRequiredColumnsForGeoRefTool(tool);
        if (missingColumnsForBG.length > 0) {
            geoRefToolBtn.setEnabled(false);
            String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>";
            for (String reqdField : missingColumnsForBG) {
                ttText += "<li>" + reqdField + "</li>";
            }
            ttText += "</ul>";
            String origTT = geoRefToolBtn.getToolTipText();
            geoRefToolBtn.setToolTipText("<html>" + origTT + ttText);
        } else {
            geoRefToolBtn.setEnabled(true);
        }
    }

    if (isReadOnly) {
        convertGeoRefFormatBtn = null;
    } else {
        convertGeoRefFormatBtn = createIconBtn("ConvertGeoRef", IconManager.IconSize.NonStd,
                "WB_CONVERT_GEO_FORMAT", false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        showGeoRefConvertDialog();
                    }
                });

        // now enable/disable the geo ref related buttons
        String[] missingGeoRefFields = getMissingGeoRefLatLonFields();
        if (missingGeoRefFields.length > 0) {
            convertGeoRefFormatBtn.setEnabled(false);
            exportKmlBtn.setEnabled(false);
            //showMapBtn.setEnabled(false);

            String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>";
            for (String reqdField : missingGeoRefFields) {
                ttText += "<li>" + reqdField + "</li>";
            }
            ttText += "</ul>";
            String origTT1 = convertGeoRefFormatBtn.getToolTipText();
            convertGeoRefFormatBtn.setToolTipText("<html>" + origTT1 + ttText);
            String origTT2 = exportKmlBtn.getToolTipText();
            exportKmlBtn.setToolTipText("<html>" + origTT2 + ttText);
            //String origTT3 = showMapBtn.getToolTipText();
            //showMapBtn.setToolTipText("<html>" + origTT3 + ttText);
        } else {
            convertGeoRefFormatBtn.setEnabled(true);
            exportKmlBtn.setEnabled(true);
            //showMapBtn.setEnabled(true);
        }
    }

    if (AppContextMgr.isSecurityOn() && !task.getPermissions().canModify()) {
        exportExcelCsvBtn = null;
    } else {
        exportExcelCsvBtn = createIconBtn("Export", IconManager.IconSize.NonStd, "WB_EXPORT_DATA", false,
                new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        doExcelCsvExport();
                    }
                });
        exportExcelCsvBtn.setEnabled(true);
    }

    uploadDatasetBtn = createIconBtn("Upload", IconManager.IconSize.Std24, "WB_UPLOAD_DATA", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    doDatasetUpload();
                }
            });
    uploadDatasetBtn.setVisible(isUploadPermitted() && !UIRegistry.isMobile());
    uploadDatasetBtn.setEnabled(canUpload());
    if (!uploadDatasetBtn.isEnabled()) {
        uploadDatasetBtn.setToolTipText(getResourceString("WB_UPLOAD_IN_PROGRESS"));
    }

    // listen to selection changes to enable/disable certain buttons
    spreadSheet.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                JStatusBar statusBar = UIRegistry.getStatusBar();
                statusBar.setText("");

                currentRow = spreadSheet.getSelectedRow();
                updateBtnUI();
            }
        }
    });

    for (int c = 0; c < spreadSheet.getTableHeader().getColumnModel().getColumnCount(); c++) {
        // TableColumn column =
        // spreadSheet.getTableHeader().getColumnModel().getColumn(spreadSheet.getTableHeader().getColumnModel().getColumnCount()-1);
        TableColumn column = spreadSheet.getTableHeader().getColumnModel().getColumn(c);
        column.setCellRenderer(new WbCellRenderer());
    }

    // setup the JFrame to show images attached to WorkbenchRows
    imageFrame = new ImageFrame(mapSize, this, this.workbench, task, isReadOnly);

    // setup the JFrame to show images attached to WorkbenchRows
    imageImportFrame = new ImageImportFrame(this, this.workbench);

    setupWorkbenchRowChangeListener();

    // setup window minimizing/maximizing listener
    JFrame topFrame = (JFrame) UIRegistry.getTopWindow();
    minMaxWindowListener = new WindowAdapter() {
        @Override
        public void windowDeiconified(WindowEvent e) {
            if (imageFrame != null && imageFrame.isVisible()) {
                imageFrame.setExtendedState(Frame.NORMAL);
            }
            if (mapFrame != null && mapFrame.isVisible()) {
                mapFrame.setExtendedState(Frame.NORMAL);
            }
        }

        @Override
        public void windowIconified(WindowEvent e) {
            if (imageFrame != null && imageFrame.isVisible()) {
                imageFrame.setExtendedState(Frame.ICONIFIED);
            }
            if (mapFrame != null && mapFrame.isVisible()) {
                mapFrame.setExtendedState(Frame.ICONIFIED);
            }
        }
    };
    topFrame.addWindowListener(minMaxWindowListener);

    if (!isReadOnly) {
        showHideUploadToolBtn = createIconBtn("ValidateWB", IconManager.IconSize.NonStd,
                "WB_HIDE_UPLOADTOOLPANEL", false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (uploadToolPanel.isExpanded()) {
                            hideUploadToolPanel();
                            showHideUploadToolBtn.setToolTipText(getResourceString("WB_SHOW_UPLOADTOOLPANEL"));
                        } else {
                            showUploadToolPanel();
                            showHideUploadToolBtn.setToolTipText(getResourceString("WB_HIDE_UPLOADTOOLPANEL"));
                        }
                    }
                });
        showHideUploadToolBtn.setEnabled(true);
    }

    // setup the mapping features
    mapFrame = new JFrame();
    mapFrame.setIconImage(IconManager.getImage("AppIcon").getImage());
    mapFrame.setTitle(getResourceString("WB_GEO_REF_DATA_MAP"));
    mapImageLabel = createLabel("");
    mapImageLabel.setSize(500, 500);
    mapFrame.add(mapImageLabel);
    mapFrame.setSize(500, 500);

    // start putting together the visible UI
    CellConstraints cc = new CellConstraints();

    JComponent[] compsArray = { addRowsBtn, deleteRowsBtn, clearCellsBtn, /*showMapBtn,*/ exportKmlBtn,
            geoRefToolBtn, convertGeoRefFormatBtn, exportExcelCsvBtn, uploadDatasetBtn, showHideUploadToolBtn };
    Vector<JComponent> availableComps = new Vector<JComponent>(
            compsArray.length + workBenchPluginSSBtns.size());
    for (JComponent c : compsArray) {
        if (c != null) {
            availableComps.add(c);
        }
    }
    for (JComponent c : workBenchPluginSSBtns) {
        availableComps.add(c);
    }

    PanelBuilder spreadSheetControlBar = new PanelBuilder(new FormLayout(
            "f:p:g,4px," + createDuplicateJGoodiesDef("p", "4px", availableComps.size()) + ",4px,", "c:p:g"));

    int x = 3;
    for (JComponent c : availableComps) {
        spreadSheetControlBar.add(c, cc.xy(x, 1));
        x += 2;
    }

    int h = 0;
    Vector<WorkbenchTemplateMappingItem> headers = new Vector<WorkbenchTemplateMappingItem>();
    headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    Collections.sort(headers);
    for (WorkbenchTemplateMappingItem mi : headers) {
        //using the workbench data model table. Not the actual specify table the column is mapped to.
        //This MIGHT be less confusing
        //System.out.println("setting header renderer for " + mi.getTableName() + "." + mi.getFieldName()); 
        spreadSheet.getColumnModel().getColumn(h++)
                .setHeaderRenderer(new WbTableHeaderRenderer(mi.getTableName()));
    }

    // NOTE: This needs to be done after the creation of the saveBtn. And after the creation of the header renderes.
    initColumnSizes(spreadSheet, saveBtn);

    // Create the Form Pane  -- needs to be done after initColumnSizes - which also sets cell editors for collumns
    if (task instanceof SGRTask) {
        formPane = new SGRFormPane(this, workbench, isReadOnly);
    } else {
        formPane = new FormPane(this, workbench, isReadOnly);
    }

    // This panel contains just the ResultSetContoller, it's needed so the RSC gets centered
    PanelBuilder rsPanel = new PanelBuilder(new FormLayout("c:p:g", "c:p:g"));
    FormValidator dummy = new FormValidator(null);
    dummy.setEnabled(true);
    resultsetController = new ResultSetController(dummy, !isReadOnly, !isReadOnly, false,
            getResourceString("Record"), model.getRowCount(), true);
    resultsetController.addListener(formPane);
    if (!isReadOnly) {
        resultsetController.getDelRecBtn().addActionListener(delAction);
    }
    //        else
    //        {
    //            resultsetController.getDelRecBtn().setVisible(false);
    //        }
    rsPanel.add(resultsetController.getPanel(), cc.xy(1, 1));

    // This panel is a single row containing the ResultSetContoller and the other controls for the Form Panel
    String colspec = "f:p:g, p, f:p:g, p";
    for (int i = 0; i < workBenchPluginFormBtns.size(); i++) {
        colspec = colspec + ", f:p, p";
    }

    PanelBuilder resultSetPanel = new PanelBuilder(new FormLayout(colspec, "c:p:g"));
    // Now put the two panel into the single row panel
    resultSetPanel.add(rsPanel.getPanel(), cc.xy(2, 1));
    if (!isReadOnly) {
        resultSetPanel.add(formPane.getControlPropsBtn(), cc.xy(4, 1));
    }
    int ccx = 6;
    for (JComponent c : workBenchPluginFormBtns) {
        resultSetPanel.add(c, cc.xy(ccx, 1));
        ccx += 2;
    }

    // Create the main panel that uses card layout for the form and spreasheet
    mainPanel = new JPanel(cardLayout = new CardLayout());

    // Add the Form and Spreadsheet to the CardLayout
    mainPanel.add(spreadSheet.getScrollPane(), PanelType.Spreadsheet.toString());
    mainPanel.add(formPane.getPane(), PanelType.Form.toString());

    // The controllerPane is a CardLayout that switches between the Spreadsheet control bar and the Form Control Bar
    controllerPane = new JPanel(cpCardLayout = new CardLayout());
    controllerPane.add(spreadSheetControlBar.getPanel(), PanelType.Spreadsheet.toString());
    controllerPane.add(resultSetPanel.getPanel(), PanelType.Form.toString());

    JLabel sep1 = new JLabel(IconManager.getIcon("Separator"));
    JLabel sep2 = new JLabel(IconManager.getIcon("Separator"));
    ssFormSwitcher = createSwitcher();

    // This works
    setLayout(new BorderLayout());

    boolean doDnDImages = AppPreferences.getLocalPrefs().getBoolean("WB_DND_IMAGES", false);
    JComponent[] ctrlCompArray1 = { importImagesBtn, toggleImageFrameBtn, carryForwardBtn, sep1, saveBtn, sep2,
            ssFormSwitcher };
    JComponent[] ctrlCompArray2 = { toggleImageFrameBtn, carryForwardBtn, sep1, saveBtn, sep2, ssFormSwitcher };
    JComponent[] ctrlCompArray = doDnDImages ? ctrlCompArray1 : ctrlCompArray2;

    Vector<Pair<JComponent, Integer>> ctrlComps = new Vector<Pair<JComponent, Integer>>();
    for (JComponent c : ctrlCompArray) {
        ctrlComps.add(new Pair<JComponent, Integer>(c, null));
    }

    String layoutStr = "";
    int compCount = 0;
    int col = 1;
    int pos = 0;
    for (Pair<JComponent, Integer> c : ctrlComps) {
        JComponent comp = c.getFirst();
        if (comp != null) {
            boolean addComp = !(comp == sep1 || comp == sep2) || compCount > 0;
            if (!addComp) {
                c.setFirst(null);
            } else {
                if (!StringUtils.isEmpty(layoutStr)) {
                    layoutStr += ",";
                    col++;
                    if (pos < ctrlComps.size() - 1) {
                        //this works because we know ssFormSwitcher is last and always non-null.
                        layoutStr += "6px,";
                        col++;
                    }
                }
                c.setSecond(col);
                if (comp == sep1 || comp == sep2) {
                    layoutStr += "6px";
                    compCount = 0;
                } else {
                    layoutStr += "p";
                    compCount++;
                }
            }
        }
        pos++;
    }
    PanelBuilder ctrlBtns = new PanelBuilder(new FormLayout(layoutStr, "c:p:g"));
    for (Pair<JComponent, Integer> c : ctrlComps) {
        if (c.getFirst() != null) {
            ctrlBtns.add(c.getFirst(), cc.xy(c.getSecond(), 1));
        }
    }

    add(mainPanel, BorderLayout.CENTER);

    FormLayout formLayout = new FormLayout("f:p:g,4px,p", "2px,f:p:g,p:g,p:g");
    PanelBuilder builder = new PanelBuilder(formLayout);

    builder.add(controllerPane, cc.xy(1, 2));
    builder.add(ctrlBtns.getPanel(), cc.xy(3, 2));

    if (!isReadOnly) {
        uploadToolPanel = new UploadToolPanel(this, UploadToolPanel.EXPANDED);
        uploadToolPanel.createUI();
        //            showHideUploadToolBtn = createIconBtn("ValidateWB", IconManager.IconSize.NonStd, "WB_HIDE_UPLOADTOOLPANEL", false, new ActionListener()
        //            {
        //                public void actionPerformed(ActionEvent ae)
        //                {
        //                    if (uploadToolPanel.isExpanded())
        //                    {
        //                       hideUploadToolPanel();
        //                       showHideUploadToolBtn.setToolTipText(getResourceString("WB_SHOW_UPLOADTOOLPANEL"));
        //                    } else
        //                    {
        //                       showUploadToolPanel();
        //                       showHideUploadToolBtn.setToolTipText(getResourceString("WB_HIDE_UPLOADTOOLPANEL"));
        //                   }
        //                }
        //            });
        //            showHideUploadToolBtn.setEnabled(true);
    }

    builder.add(uploadToolPanel, cc.xywh(1, 3, 3, 1));
    builder.add(findPanel, cc.xywh(1, 4, 3, 1));

    add(builder.getPanel(), BorderLayout.SOUTH);

    resultsetController.addListener(new ResultSetControllerListener() {
        public boolean indexAboutToChange(int oldIndex, int newIndex) {
            return true;
        }

        public void indexChanged(int newIndex) {
            if (imageFrame != null) {
                if (newIndex > -1) {
                    int index = spreadSheet.convertRowIndexToModel(newIndex);
                    imageFrame.setRow(workbench.getRow(index));
                } else {
                    imageFrame.setRow(null);
                }
            }
        }

        public void newRecordAdded() {
            // do nothing
        }
    });
    //compareSchemas();
    if (getIncremental() && workbenchValidator == null) {
        buildValidator();
    }

    //        int c = 0;
    //        Vector<WorkbenchTemplateMappingItem> headers = new Vector<WorkbenchTemplateMappingItem>();
    //        headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    //        Collections.sort(headers);
    //        for (WorkbenchTemplateMappingItem mi : headers)
    //        {
    //           //using the workbench data model table. Not the actual specify table the column is mapped to.
    //           //This MIGHT be less confusing
    //           //System.out.println("setting header renderer for " + mi.getTableName() + "." + mi.getFieldName()); 
    //           spreadSheet.getColumnModel().getColumn(c++).setHeaderRenderer(new WbTableHeaderRenderer(mi.getTableName()));
    //        }
    //        
    //        // NOTE: This needs to be done after the creation of the saveBtn. And after the creation of the header renderes.
    //        initColumnSizes(spreadSheet, saveBtn);

    // See if we need to make the Image Frame visible
    // Commenting this out for now because it is so annoying.

    if (showImageView || hasOneOrMoreImages) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                toggleImageFrameVisible();

                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        final Frame f = (Frame) UIRegistry.get(UIRegistry.FRAME);
                        f.toFront();
                        f.requestFocus();
                    }
                });
            }
        });
    }

    ((WorkbenchTask) ContextMgr.getTaskByClass(WorkbenchTask.class)).opening(this);
    ((SGRTask) ContextMgr.getTaskByClass(SGRTask.class)).opening(this);
}

From source file:org.omegat.gui.scripting.ScriptingWindow.java

private JMenuBar createMenuBar() {

    mb = new JMenuBar();
    JMenu menu = new JMenu();
    Mnemonics.setLocalizedText(menu, OStrings.getString("SCW_MENU_TITLE"));

    JMenuItem item;/* ww w . j  a va 2  s .c  o  m*/

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_NEW_SCRIPT"));
    item.addActionListener(new NewScriptAction());
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(item);

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_SAVE_SCRIPT"));
    item.addActionListener(new SaveScriptAction());
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(item);

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_RUN_SCRIPT"));
    item.addActionListener(new RunScriptAction());
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu.add(item);

    menu.addSeparator();

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_SET_SCRIPTS_FOLDER"));
    item.addActionListener(new SelectScriptFolderAction());
    menu.add(item);

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_ACCESS_FOLDER"));
    item.addActionListener(new ExploreScriptFolderAction());
    menu.add(item);

    menu.addSeparator();

    item = new JMenuItem();
    Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_CLOSE"));
    item.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(e -> {
        frame.setVisible(false);
        frame.dispose();
    });
    menu.add(item);

    PropertiesShortcuts.MainMenuShortcuts.bindKeyStrokes(menu);

    mb.add(menu);

    // Edit Menu
    m_txtScriptEditor.enhanceMenu(mb);

    buildSetsMenu(mb);

    return mb;
}