Example usage for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem

List of usage examples for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem

Introduction

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

Prototype

public JCheckBoxMenuItem(Action a) 

Source Link

Document

Creates a menu item whose properties are taken from the Action supplied.

Usage

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

/**
 * Creates a Localized JCheckBoxMenuItem.
 * @param labelKey//from  ww  w  .  ja  v a2s  .  com
 * @param mnemonicKey
 * @param accessibleDescriptionKey
 * @param enabled
 * @param action
 * @return
 */
public static JCheckBoxMenuItem createLocalizedCheckBoxMenuItem(final String labelKey, final String mnemonicKey,
        final String accessibleDescriptionKey, final boolean enabled, final AbstractAction action) {
    JCheckBoxMenuItem mi = new JCheckBoxMenuItem(getResourceString(labelKey));
    setLocalizedMnemonic(mi, getResourceString(mnemonicKey));

    if (isNotEmpty(accessibleDescriptionKey)) {
        mi.getAccessibleContext().setAccessibleDescription(getResourceString(accessibleDescriptionKey));
    }
    if (action != null) {
        mi.addActionListener(action);
        action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi));
        action.setEnabled(enabled);
    }

    return mi;
}

From source file:ca.phon.ipamap.IpaMap.java

/**
 * Create the context menu based on source component
 *//*w  w  w. j  av  a 2 s. c o  m*/
public void setupContextMenu(JPopupMenu menu, JComponent comp) {
    final CommonModuleFrame parentFrame = (CommonModuleFrame) SwingUtilities
            .getAncestorOfClass(CommonModuleFrame.class, comp);
    if (parentFrame != null) {
        final PhonUIAction toggleAlwaysOnTopAct = new PhonUIAction(parentFrame, "setAlwaysOnTop",
                !parentFrame.isAlwaysOnTop());
        toggleAlwaysOnTopAct.putValue(PhonUIAction.NAME, "Always on top");
        toggleAlwaysOnTopAct.putValue(PhonUIAction.SELECTED_KEY, parentFrame.isAlwaysOnTop());
        final JCheckBoxMenuItem toggleAlwaysOnTopItem = new JCheckBoxMenuItem(toggleAlwaysOnTopAct);
        menu.add(toggleAlwaysOnTopItem);
    }

    // button options first
    if (comp instanceof CellButton) {
        CellButton btn = (CellButton) comp;
        Cell cell = btn.cell;

        // copy to clipboard options
        String cellData = cell.getText().replaceAll("" + (char) 0x25cc, "");
        PhonUIAction copyToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", cellData);
        copyToClipboardAct.putValue(PhonUIAction.NAME, "Copy character (" + cell.getText() + ")");
        JMenuItem copyToClipboardItem = new JMenuItem(copyToClipboardAct);
        menu.add(copyToClipboardItem);

        String htmlVal = new String();
        for (Character c : cellData.toCharArray()) {
            htmlVal += "&#" + (int) c + ";";
        }
        PhonUIAction copyHTMLToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", htmlVal);
        copyHTMLToClipboardAct.putValue(PhonUIAction.NAME, "Copy as HTML (" + htmlVal + ")");
        JMenuItem copyHTMLToClipboardItem = new JMenuItem(copyHTMLToClipboardAct);
        menu.add(copyHTMLToClipboardItem);

        String hexVal = new String();
        for (Character c : cellData.toCharArray()) {
            hexVal += (hexVal.length() > 0 ? " " : "") + Integer.toHexString((int) c);
        }
        hexVal = hexVal.toUpperCase();
        PhonUIAction copyHEXToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", hexVal);
        copyHEXToClipboardAct.putValue(PhonUIAction.NAME, "Copy as Unicode HEX (" + hexVal + ")");
        JMenuItem copyHEXToClipboardItem = new JMenuItem(copyHEXToClipboardAct);
        menu.add(copyHEXToClipboardItem);

        menu.addSeparator();
        if (isInFavorites(cell)) {
            PhonUIAction removeFromFavAct = new PhonUIAction(this, "onRemoveCellFromFavorites", cell);
            removeFromFavAct.putValue(Action.NAME, "Remove from favorites");
            removeFromFavAct.putValue(Action.SHORT_DESCRIPTION, "Remove button from list of favorites");
            JMenuItem removeFromFavItem = new JMenuItem(removeFromFavAct);
            menu.add(removeFromFavItem);
        } else {
            PhonUIAction addToFavAct = new PhonUIAction(this, "onAddCellToFavorites", cell);
            addToFavAct.putValue(Action.NAME, "Add to favorites");
            addToFavAct.putValue(Action.SHORT_DESCRIPTION, "Add button to list of favorites");
            JMenuItem addToFavItem = new JMenuItem(addToFavAct);
            menu.add(addToFavItem);
        }
        menu.addSeparator();
    }

    // section scroll-tos
    JMenuItem gotoTitleItem = new JMenuItem("Scroll to:");
    gotoTitleItem.setEnabled(false);
    menu.add(gotoTitleItem);

    for (JXButton toggleBtn : toggleButtons) {
        PhonUIAction gotoAct = new PhonUIAction(this, "onGoto", toggleBtn);
        gotoAct.putValue(Action.NAME, toggleBtn.getText());
        gotoAct.putValue(Action.SHORT_DESCRIPTION, "Scroll to " + toggleBtn.getText());
        JMenuItem gotoItem = new JMenuItem(gotoAct);
        menu.add(gotoItem);
    }

    menu.addSeparator();

    // setup font scaler
    final JLabel smallLbl = new JLabel("A");
    smallLbl.setFont(getFont().deriveFont(12.0f));
    smallLbl.setHorizontalAlignment(SwingConstants.CENTER);
    JLabel largeLbl = new JLabel("A");
    largeLbl.setFont(getFont().deriveFont(24.0f));
    largeLbl.setHorizontalAlignment(SwingConstants.CENTER);

    final JSlider scaleSlider = new JSlider(1, 101);
    scaleSlider.setValue((int) (scale * 100));
    scaleSlider.setMajorTickSpacing(20);
    scaleSlider.setMinorTickSpacing(10);
    scaleSlider.setSnapToTicks(true);
    scaleSlider.setPaintTicks(true);
    scaleSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent arg0) {
            int sliderVal = scaleSlider.getValue();

            float scale = (float) sliderVal / (float) 100;

            _cFont = null;

            setSavedScale(scale);
            setScale(scale);

        }
    });

    FormLayout scaleLayout = new FormLayout("3dlu, center:pref, fill:pref:grow, center:pref, 3dlu", "pref");
    CellConstraints cc = new CellConstraints();
    JPanel scalePanel = new JPanel(scaleLayout) {
        @Override
        public Insets getInsets() {
            Insets retVal = super.getInsets();

            retVal.left += UIManager.getIcon("Tree.collapsedIcon").getIconWidth();

            return retVal;
        }
    };
    scalePanel.add(smallLbl, cc.xy(2, 1));
    scalePanel.add(scaleSlider, cc.xy(3, 1));
    scalePanel.add(largeLbl, cc.xy(4, 1));

    JMenuItem scaleItem = new JMenuItem("Font size");
    scaleItem.setEnabled(false);
    menu.add(scaleItem);
    menu.add(scalePanel);

    menu.addSeparator();

    // highlighting
    PhonUIAction onToggleHighlightAct = new PhonUIAction(this, "onToggleHighlightRecent");
    onToggleHighlightAct.putValue(PhonUIAction.NAME, "Highlight recently used");
    onToggleHighlightAct.putValue(PhonUIAction.SELECTED_KEY, isHighlightRecent());
    JCheckBoxMenuItem onToggleHighlightItm = new JCheckBoxMenuItem(onToggleHighlightAct);
    menu.add(onToggleHighlightItm);
}

From source file:gda.plots.SimplePlot.java

/**
 * Creates the JPopupMenu, overrides (but uses) the super class method adding items for the Magnification and
 * Logarithmic axes./*from ww w  . ja  v a2s .  c  o  m*/
 * 
 * @param properties
 *            boolean if true appears on menu
 * @param save
 *            boolean if true appears on menu
 * @param print
 *            boolean if true appears on menu
 * @param zoom
 *            boolean if true appears on menu
 * @return the popup menu
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {
    // Create the popup without the zooming parts
    JPopupMenu jpm = super.createPopupMenu(properties, false, print, false);

    // as the save function on the chartpanel doesn't remember its location,
    // we shall remove it and and create a new save option
    if (save) {
        jpm.add(new JSeparator());

        // The save button

        saveButton = new JMenuItem("Save As");
        saveButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                saveAs();
            }
        });

        jpm.add(saveButton);
    }

    jpm.add(new JSeparator());

    // This button toggles the data-type magnification
    magnifyDataButton = new JCheckBoxMenuItem("Magnify(Data)");
    magnifyDataButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setMagnifyingData(!isMagnifyingData());
        }
    });
    jpm.add(magnifyDataButton);

    jpm.add(new JSeparator());

    // The zoomButton toggles the value of zooming.
    zoomButton = new JCheckBoxMenuItem("Zoom");
    zoomButton.setHorizontalTextPosition(SwingConstants.LEFT);
    zoomButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setZooming(!isZooming());
        }
    });
    jpm.add(zoomButton);

    // The unZoomButton is not a toggle, it undoes the last zoom.
    unZoomButton = new JMenuItem("UnZoom");
    unZoomButton.setEnabled(false);
    unZoomButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            unZoom();
        }
    });
    jpm.add(unZoomButton);

    if (type == LINECHART) {
        jpm.add(new JSeparator());

        turboModeButton = new JCheckBoxMenuItem("Turbo Mode");
        turboModeButton.setHorizontalTextPosition(SwingConstants.LEFT);
        turboModeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setTurboMode(!isTurboMode());
            }
        });
        turboModeButton.setSelected(isTurboMode());
        jpm.add(turboModeButton);

        stripModeButton = new JCheckBoxMenuItem("StripChart Mode");
        stripModeButton.setHorizontalTextPosition(SwingConstants.LEFT);
        stripModeButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String widthStr = "";
                {
                    double width = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLength()
                            : Double.MAX_VALUE;
                    widthStr = getXAxisNumberFormat().format(width);
                    widthStr = JOptionPane.showInputDialog(null,
                            "Enter the x strip width - clear for autorange", widthStr);
                    if (widthStr == null) //cancel
                        return;
                }
                Double newStripWidth = null;
                if (!widthStr.isEmpty()) {
                    try {
                        newStripWidth = Double.valueOf(widthStr);
                    } catch (Exception ex) {
                        logger.error(ex.getMessage(), ex);
                    }
                }
                setStripWidth(newStripWidth);
            }
        });
        stripModeButton.setSelected(isStripMode());
        jpm.add(stripModeButton);

        xLimitsButton = new JCheckBoxMenuItem("Fix X Axis Limits");
        xLimitsButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String minStr = "";
                {
                    double min = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLowerBound()
                            : Double.MAX_VALUE;
                    minStr = getXAxisNumberFormat().format(min);
                    minStr = JOptionPane.showInputDialog(null, "Enter the min x value - clear for autorange",
                            minStr);
                    if (minStr == null) //cancel
                        return;

                }
                String maxStr = "";
                if (!minStr.isEmpty()) {
                    double max = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getUpperBound()
                            : -Double.MAX_VALUE;
                    maxStr = getXAxisNumberFormat().format(max);
                    maxStr = JOptionPane.showInputDialog(null, "Enter the max x value - clear for autorange",
                            maxStr);
                    if (maxStr == null) //cancel
                        return;
                }
                Range newBounds = null;
                if (!maxStr.isEmpty() && !minStr.isEmpty()) {
                    try {
                        newBounds = new Range(Double.valueOf(minStr), Double.valueOf(maxStr));
                    } catch (Exception ex) {
                        logger.error(ex.getMessage(), ex);
                    }
                }
                setDomainBounds(newBounds);
            }
        });
        xLimitsButton.setSelected(false);
        jpm.add(xLimitsButton);

    }

    jpm.add(new JSeparator());

    xLogLinButton = new JMenuItem("Logarithmic X axis");
    xLogLinButton.setEnabled(true);
    xLogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setXAxisLogarithmic(!isXAxisLogarithmic());
        }
    });
    jpm.add(xLogLinButton);

    yLogLinButton = new JMenuItem("Logarithmic Y axis");
    yLogLinButton.setEnabled(true);
    yLogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setYAxisLogarithmic(!isYAxisLogarithmic());
        }
    });
    jpm.add(yLogLinButton);

    y2LogLinButton = new JMenuItem("Logarithmic Y2 axis");
    y2LogLinButton.setEnabled(false);
    y2LogLinButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setYAxisTwoLogarithmic(!isYAxisTwoLogarithmic());
        }
    });

    jpm.add(y2LogLinButton);

    jpm.add(new JSeparator());

    // Adding a new button to allow the user to select the formatting they
    // want on the x and y axis
    xFormatButton = new JMenuItem("X Axis Format");
    xFormatButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String Format = getXAxisNumberFormat().format(0.0);
            String input = JOptionPane.showInputDialog(null,
                    "Enter the new formatting for the X axis, of the form 0.0000E00", Format);
            // try forcing this into some objects
            try {
                setScientificXAxis(new DecimalFormat(input));
            } catch (Exception err) {
                logger.error("Could not use this format due to {}", e);
            }
        }
    });
    jpm.add(xFormatButton);

    // Adding a new button to allow the user to select the formatting they
    // want on the x and y axis
    yFormatButton = new JMenuItem("Y Axis Format");
    yFormatButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String Format = getYAxisNumberFormat().format(0.0);
            String input = JOptionPane.showInputDialog(null,
                    "Enter the new formatting for the Y axis, of the form 0.0000E00", Format);
            // try forcing this into some objects
            try {
                setScientificYAxis(new DecimalFormat(input));
            } catch (Exception err) {
                logger.error("Could not use this format due to {}", e);
            }
        }
    });
    jpm.add(yFormatButton);

    // The zoomButton toggles the value of zooming.
    xAxisVerticalTicksButton = new JCheckBoxMenuItem("Vertical X Ticks");
    xAxisVerticalTicksButton.setHorizontalTextPosition(SwingConstants.LEFT);
    xAxisVerticalTicksButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalXAxisTicks(xAxisVerticalTicksButton.isSelected());
        }
    });
    jpm.add(xAxisVerticalTicksButton);

    return jpm;
}

From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java

@Override
public JPopupMenu getComponentPopupMenu() {
    JPopupMenu popupMenu = getFileChooser().getComponentPopupMenu();

    if (popupMenu != null) {
        return popupMenu;
    }// w  w w. j  ava  2s . co m

    JMenu aViewMenu = getViewMenu();

    if (contextMenu == null) {
        contextMenu = new JPopupMenu();

        if (aViewMenu != null) {
            contextMenu.add(aViewMenu);

            if (listViewWindowsStyle) {
                contextMenu.addSeparator();
            }
        }

        ActionMap actionMap = getActionMap();
        Action refreshAction = actionMap.get(ACTION_REFRESH);
        Action aNewFolderAction = actionMap.get(ACTION_NEW_FOLDER);
        Action showHiddenFiles = actionMap.get(ACTION_VIEW_HIDDEN);

        if (refreshAction != null) {
            contextMenu.add(refreshAction);

            if (listViewWindowsStyle && (aNewFolderAction != null)) {
                contextMenu.addSeparator();
            }
        }

        if (showHiddenFiles != null) {
            JCheckBoxMenuItem menuitem = new JCheckBoxMenuItem(showHiddenFiles);
            menuitem.setSelected((Boolean) showHiddenFiles.getValue(Action.SELECTED_KEY));
            contextMenu.add(menuitem);
        }

        if (aNewFolderAction != null) {
            contextMenu.add(aNewFolderAction);
        }
    }

    if (aViewMenu != null) {
        aViewMenu.getPopupMenu().setInvoker(aViewMenu);
    }

    return contextMenu;
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * Create menus/*from   w w w .  j a va2s  .c  o  m*/
 */
public JMenuBar createMenus() {
    JMenuBar mb = new JMenuBar();
    JMenuItem mi;

    //--------------------------------------------------------------------
    //-- File Menu
    //--------------------------------------------------------------------

    JMenu menu = null;

    if (!UIHelper.isMacOS() || !isWorkbenchOnly) {
        menu = UIHelper.createLocalizedMenu(mb, "Specify.FILE_MENU", "Specify.FILE_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!isWorkbenchOnly) {
        // Add Menu for switching Collection
        String title = "Specify.CHANGE_COLLECTION"; //$NON-NLS-1$
        String mnu = "Specify.CHANGE_COLL_MNEU"; //$NON-NLS-1$
        changeCollectionMenuItem = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null);
        changeCollectionMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                if (SubPaneMgr.getInstance().aboutToShutdown()) {

                    // Actually we really need to start over
                    // "true" means that it should NOT use any cached values it can find to automatically initialize itself
                    // instead it should ask the user any questions as if it were starting over
                    restartApp(null, databaseName, userName, true, false);
                }
            }
        });

        menu.addMenuListener(new MenuListener() {
            @Override
            public void menuCanceled(MenuEvent e) {
            }

            @Override
            public void menuDeselected(MenuEvent e) {
            }

            @Override
            public void menuSelected(MenuEvent e) {
                boolean enable = Uploader.getCurrentUpload() == null
                        && ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getNumOfCollectionsForUser() > 1
                        && !TaskMgr.areTasksDisabled();

                changeCollectionMenuItem.setEnabled(enable);
            }

        });
    }

    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        if (!UIRegistry.isMobile()) {
            menu.addSeparator();
        }
        String title = "Specify.EXIT"; //$NON-NLS-1$
        String mnu = "Specify.Exit_MNEU"; //$NON-NLS-1$
        mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, true, null);
        if (!UIHelper.isMacOS()) {
            mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK));
        }
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doExit(true);
            }
        });
    }

    menu = UIRegistry.getInstance().createEditMenu();
    mb.add(menu);

    //menu = UIHelper.createMenu(mb, "EditMenu", "EditMneu");
    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        menu.addSeparator();
        String title = "Specify.PREFERENCES"; //$NON-NLS-1$
        String mnu = "Specify.PREFERENCES_MNEU";//$NON-NLS-1$
        mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doPreferences();
            }
        });
        mi.setEnabled(true);
    }

    //--------------------------------------------------------------------
    //-- Data Menu
    //--------------------------------------------------------------------
    JMenu dataMenu = UIHelper.createLocalizedMenu(mb, "Specify.DATA_MENU", "Specify.DATA_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    ResultSetController.addMenuItems(dataMenu);
    dataMenu.addSeparator();

    // Save And New Menu Item
    Action saveAndNewAction = new AbstractAction(getResourceString("Specify.SAVE_AND_NEW")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.setSaveAndNew(((JCheckBoxMenuItem) e.getSource()).isSelected());
            }
        }
    };
    saveAndNewAction.setEnabled(false);
    JCheckBoxMenuItem saveAndNewCBMI = new JCheckBoxMenuItem(saveAndNewAction);
    dataMenu.add(saveAndNewCBMI);
    UIRegistry.register("SaveAndNew", saveAndNewCBMI); //$NON-NLS-1$
    UIRegistry.registerAction("SaveAndNew", saveAndNewAction); //$NON-NLS-1$
    mb.add(dataMenu);

    // Configure Carry Forward
    Action configCarryForwardAction = new AbstractAction(
            getResourceString("Specify.CONFIG_CARRY_FORWARD_MENU")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.configureCarryForward();
            }
        }
    };
    configCarryForwardAction.setEnabled(false);
    JMenuItem configCFWMI = new JMenuItem(configCarryForwardAction);
    dataMenu.add(configCFWMI);
    UIRegistry.register("ConfigCarryForward", configCFWMI); //$NON-NLS-1$
    UIRegistry.registerAction("ConfigCarryForward", configCarryForwardAction); //$NON-NLS-1$
    mb.add(dataMenu);

    //---------------------------------------
    // Carry Forward Menu Item (On / Off)
    Action carryForwardAction = new AbstractAction(getResourceString("Specify.CARRY_FORWARD_CHECKED_MENU")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.toggleCarryForward();
                ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isDoCarryForward());
            }
        }
    };
    carryForwardAction.setEnabled(false);
    JCheckBoxMenuItem carryForwardCBMI = new JCheckBoxMenuItem(carryForwardAction);
    dataMenu.add(carryForwardCBMI);
    UIRegistry.register("CarryForward", carryForwardCBMI); //$NON-NLS-1$
    UIRegistry.registerAction("CarryForward", carryForwardAction); //$NON-NLS-1$
    mb.add(dataMenu);

    if (!isWorkbenchOnly) {
        final String AUTO_NUM = "AutoNumbering";
        //---------------------------------------
        // AutoNumber Menu Item (On / Off)
        Action autoNumberOnOffAction = new AbstractAction(
                getResourceString("FormViewObj.SET_AUTONUMBER_ONOFF")) { //$NON-NLS-1$
            public void actionPerformed(ActionEvent e) {
                FormViewObj fvo = getCurrentFVO();
                if (fvo != null) {
                    fvo.toggleAutoNumberOnOffState();
                    ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isAutoNumberOn());
                }
            }
        };
        autoNumberOnOffAction.setEnabled(false);
        JCheckBoxMenuItem autoNumCBMI = new JCheckBoxMenuItem(autoNumberOnOffAction);
        dataMenu.add(autoNumCBMI);
        UIRegistry.register(AUTO_NUM, autoNumCBMI); //$NON-NLS-1$
        UIRegistry.registerAction(AUTO_NUM, autoNumberOnOffAction); //$NON-NLS-1$
    }

    if (System.getProperty("user.name").equals("rods")) {
        dataMenu.addSeparator();

        AbstractAction gpxAction = new AbstractAction("GPS Data") {
            @Override
            public void actionPerformed(ActionEvent e) {
                GPXPanel.getDlgInstance().setVisible(true);
            }
        };
        JMenuItem gpxMI = new JMenuItem(gpxAction);
        dataMenu.add(gpxMI);
        UIRegistry.register("GPXDlg", gpxMI); //$NON-NLS-1$
        UIRegistry.registerAction("GPXDlg", gpxAction); //$NON-NLS-1$
    }

    mb.add(dataMenu);

    SubPaneMgr.getInstance(); // force creating of the Mgr so the menu Actions are created.

    //--------------------------------------------------------------------
    //-- System Menu
    //--------------------------------------------------------------------

    if (!isWorkbenchOnly) {
        // TODO This needs to be moved into the SystemTask, but right now there is no way
        // to ask a task for a menu.
        menu = UIHelper.createLocalizedMenu(mb, "Specify.SYSTEM_MENU", "Specify.SYSTEM_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$

        /*if (true)
        {
        menu = UIHelper.createMenu(mb, "Forms", "o");
        Action genForms = new AbstractAction()
        {
            public void actionPerformed(ActionEvent ae)
            {
                FormGenerator fg = new FormGenerator();
                fg.generateForms();
            }
        };
        mi = UIHelper.createMenuItemWithAction(menu, "Generate All Forms", "G", "", true, genForms);
        }*/
    }

    //--------------------------------------------------------------------
    //-- Tab Menu
    //--------------------------------------------------------------------
    menu = UIHelper.createLocalizedMenu(mb, "Specify.TABS_MENU", "Specify.TABS_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$

    String ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MENU");
    String mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseCurrent"));
    if (!UIHelper.isMacOS()) {
        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK));
    }

    ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MENU");
    mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAll"));
    if (!UIHelper.isMacOS()) {
        mi.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    }

    ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MENU");
    mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAllBut"));

    menu.addSeparator();

    // Configure Task
    JMenuItem configTaskMI = new JMenuItem(getAction("ConfigureTask"));
    menu.add(configTaskMI);
    //UIRegistry.register("ConfigureTask", configTaskMI); //$NON-NLS-1$

    //--------------------------------------------------------------------
    //-- Debug Menu
    //--------------------------------------------------------------------

    boolean doDebug = AppPreferences.getLocalPrefs().getBoolean("debug.menu", false);
    if (!UIRegistry.isRelease() || doDebug) {
        menu = UIHelper.createLocalizedMenu(mb, "Specify.DEBUG_MENU", "Specify.DEBUG_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
        String ttle = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ 
        String mneu = "Specify.SHOW_LOC_PREF_MNEU";//$NON-NLS-1$ 
        String desc = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$ 
            public void actionPerformed(ActionEvent ae) {
                openLocalPrefs();
            }
        });

        ttle = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ 
        mneu = "Specify.SHOW_REM_PREFS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                openRemotePrefs();
            }
        });

        menu.addSeparator();

        ttle = "Specify.CONFIG_LOGGERS";//$NON-NLS-1$ 
        mneu = "Specify.CONFIG_LOGGERS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.CONFIG_LOGGER";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                final LoggerDialog dialog = new LoggerDialog(topFrame);
                UIHelper.centerAndShow(dialog);
            }
        });

        ttle = "Specify.CONFIG_DEBUG_LOGGERS";//$NON-NLS-1$ 
        mneu = "Specify.CONFIG_DEBUG_LOGGERS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.CONFIG_DEBUG_LOGGER";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                DebugLoggerDialog dialog = new DebugLoggerDialog(topFrame);
                UIHelper.centerAndShow(dialog);
            }
        });

        menu.addSeparator();

        ttle = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ 
        mneu = "Specify.SHOW_MEM_STATS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                System.gc();
                System.runFinalization();

                // Get current size of heap in bytes
                double meg = 1024.0 * 1024.0;
                double heapSize = Runtime.getRuntime().totalMemory() / meg;

                // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
                // Any attempt will result in an OutOfMemoryException.
                double heapMaxSize = Runtime.getRuntime().maxMemory() / meg;

                // Get amount of free memory within the heap in bytes. This size will increase
                // after garbage collection and decrease as new objects are created.
                double heapFreeSize = Runtime.getRuntime().freeMemory() / meg;

                UIRegistry.getStatusBar()
                        .setText(String.format("Heap Size: %7.2f    Max: %7.2f    Free: %7.2f   Used: %7.2f", //$NON-NLS-1$
                                heapSize, heapMaxSize, heapFreeSize, (heapSize - heapFreeSize)));
            }
        });

        JMenu prefsMenu = new JMenu(UIRegistry.getResourceString("Specify.PREFS_IMPORT_EXPORT")); //$NON-NLS-1$
        menu.add(prefsMenu);
        ttle = "Specify.IMPORT_MENU";//$NON-NLS-1$ 
        mneu = "Specify.IMPORT_MNEU";//$NON-NLS-1$ 
        desc = "Specify.IMPORT_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                importPrefs();
            }
        });
        ttle = "Specify.EXPORT_MENU";//$NON-NLS-1$ 
        mneu = "Specify.EXPORT_MNEU";//$NON-NLS-1$ 
        desc = "Specify.EXPORT_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                exportPrefs();
            }
        });

        ttle = "Associate Storage Items";//$NON-NLS-1$ 
        mneu = "A";//$NON-NLS-1$ 
        desc = "";//$NON-NLS-1$ 
        mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                associateStorageItems();
            }
        });

        ttle = "Load GPX Points";//$NON-NLS-1$ 
        mneu = "a";//$NON-NLS-1$ 
        desc = "";//$NON-NLS-1$ 
        mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                CustomDialog dlg = GPXPanel.getDlgInstance();
                if (dlg != null) {
                    dlg.setVisible(true);
                }
            }
        });

        JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem("Security Activated"); //$NON-NLS-1$
        menu.add(cbMenuItem);
        cbMenuItem.setSelected(AppContextMgr.isSecurityOn());
        cbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                boolean isSecurityOn = !SpecifyAppContextMgr.isSecurityOn();
                AppContextMgr.getInstance().setSecurity(isSecurityOn);
                ((JMenuItem) ae.getSource()).setSelected(isSecurityOn);

                JLabel secLbl = statusField.getSectionLabel(3);
                if (secLbl != null) {
                    secLbl.setIcon(IconManager.getImage(isSecurityOn ? "SecurityOn" : "SecurityOff",
                            IconManager.IconSize.Std16));
                    secLbl.setHorizontalAlignment(SwingConstants.CENTER);
                    secLbl.setToolTipText(getResourceString("Specify.SEC_" + (isSecurityOn ? "ON" : "OFF")));
                }
            }
        });

        JMenuItem sizeMenuItem = new JMenuItem("Set to " + PREFERRED_WIDTH + "x" + PREFERRED_HEIGHT); //$NON-NLS-1$
        menu.add(sizeMenuItem);
        sizeMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                topFrame.setSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
            }
        });
    }

    //----------------------------------------------------
    //-- Helper Menu
    //----------------------------------------------------

    JMenu helpMenu = UIHelper.createLocalizedMenu(mb, "Specify.HELP_MENU", "Specify.HELP_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    HelpMgr.createHelpMenuItem(helpMenu, getResourceString("SPECIFY_HELP")); //$NON-NLS-1$
    helpMenu.addSeparator();

    String ttle = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$ 
    String mneu = "Specify.LOG_SHOW_FILES_MNEU";//$NON-NLS-1$ 
    String desc = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    helpMenu.addSeparator();
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            AppBase.displaySpecifyLogFiles();
        }
    });

    ttle = "SecurityAdminTask.CHANGE_PWD_MENU"; //$NON-NLS-1$
    mneu = "SecurityAdminTask.CHANGE_PWD_MNEU"; //$NON-NLS-1$
    desc = "SecurityAdminTask.CHANGE_PWD_DESC"; //$NON-NLS-1$
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            SecurityAdminTask.changePassword(true);
        }
    });

    ttle = "Specify.CHECK_UPDATE";//$NON-NLS-1$ 
    mneu = "Specify.CHECK_UPDATE_MNEU";//$NON-NLS-1$ 
    desc = "Specify.CHECK_UPDATE_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            checkForUpdates();
        }
    });

    ttle = "Specify.AUTO_REG";//$NON-NLS-1$ 
    mneu = "Specify.AUTO_REG_MNEU";//$NON-NLS-1$ 
    desc = "Specify.AUTO_REG_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            RegisterSpecify.register(true, 0);
        }
    });

    ttle = "Specify.SA_REG";//$NON-NLS-1$ 
    mneu = "Specify.SA_REG_MNEU";//$NON-NLS-1$ 
    desc = "Specify.SA_REG_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            RegisterSpecify.registerISA();
        }
    });

    ttle = "Specify.FEEDBACK";//$NON-NLS-1$ 
    mneu = "Specify.FB_MNEU";//$NON-NLS-1$ 
    desc = "Specify.FB_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            FeedBackDlg feedBackDlg = new FeedBackDlg();
            feedBackDlg.sendFeedback();
        }
    });

    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        helpMenu.addSeparator();

        ttle = "Specify.ABOUT";//$NON-NLS-1$ 
        mneu = "Specify.ABOUTMNEU";//$NON-NLS-1$ 
        desc = "Specify.ABOUT";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doAbout();
            }
        });
    }
    return mb;
}

From source file:com.nikonhacker.gui.EmulatorUI.java

@SuppressWarnings("MagicConstant")
protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenuItem tmpMenuItem;/*www  .j a v  a  2 s  .  c  o  m*/

    //Set up the file menu.
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);

    //load image
    for (int chip = 0; chip < 2; chip++) {
        loadMenuItem[chip] = new JMenuItem("Load " + Constants.CHIP_LABEL[chip] + " firmware image");
        if (chip == Constants.CHIP_FR)
            loadMenuItem[chip].setMnemonic(KEY_EVENT_LOAD);
        loadMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_LOAD, KEY_CHIP_MODIFIER[chip]));
        loadMenuItem[chip].setActionCommand(COMMAND_IMAGE_LOAD[chip]);
        loadMenuItem[chip].addActionListener(this);
        fileMenu.add(loadMenuItem[chip]);
    }

    fileMenu.add(new JSeparator());

    //decoder
    tmpMenuItem = new JMenuItem("Decode firmware");
    tmpMenuItem.setMnemonic(KeyEvent.VK_D);
    tmpMenuItem.setActionCommand(COMMAND_DECODE);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    //encoder
    tmpMenuItem = new JMenuItem("Encode firmware (alpha)");
    tmpMenuItem.setMnemonic(KeyEvent.VK_E);
    tmpMenuItem.setActionCommand(COMMAND_ENCODE);
    tmpMenuItem.addActionListener(this);
    //        fileMenu.add(tmpMenuItem);

    fileMenu.add(new JSeparator());

    //decoder
    tmpMenuItem = new JMenuItem("Decode lens correction data");
    //tmpMenuItem.setMnemonic(KeyEvent.VK_D);
    tmpMenuItem.setActionCommand(COMMAND_DECODE_NKLD);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    fileMenu.add(new JSeparator());

    //Save state
    tmpMenuItem = new JMenuItem("Save state");
    tmpMenuItem.setActionCommand(COMMAND_SAVE_STATE);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    //Load state
    tmpMenuItem = new JMenuItem("Load state");
    tmpMenuItem.setActionCommand(COMMAND_LOAD_STATE);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    fileMenu.add(new JSeparator());

    //quit
    tmpMenuItem = new JMenuItem("Quit");
    tmpMenuItem.setMnemonic(KEY_EVENT_QUIT);
    tmpMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_QUIT, ActionEvent.ALT_MASK));
    tmpMenuItem.setActionCommand(COMMAND_QUIT);
    tmpMenuItem.addActionListener(this);
    fileMenu.add(tmpMenuItem);

    //Set up the run menu.
    JMenu runMenu = new JMenu("Run");
    runMenu.setMnemonic(KeyEvent.VK_R);
    menuBar.add(runMenu);

    for (int chip = 0; chip < 2; chip++) {
        //emulator play
        playMenuItem[chip] = new JMenuItem("Start (or resume) " + Constants.CHIP_LABEL[chip] + " emulator");
        playMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_RUN[chip], ActionEvent.ALT_MASK));
        playMenuItem[chip].setActionCommand(COMMAND_EMULATOR_PLAY[chip]);
        playMenuItem[chip].addActionListener(this);
        runMenu.add(playMenuItem[chip]);

        //emulator debug
        debugMenuItem[chip] = new JMenuItem("Debug " + Constants.CHIP_LABEL[chip] + " emulator");
        debugMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_DEBUG[chip], ActionEvent.ALT_MASK));
        debugMenuItem[chip].setActionCommand(COMMAND_EMULATOR_DEBUG[chip]);
        debugMenuItem[chip].addActionListener(this);
        runMenu.add(debugMenuItem[chip]);

        //emulator pause
        pauseMenuItem[chip] = new JMenuItem("Pause " + Constants.CHIP_LABEL[chip] + " emulator");
        pauseMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_PAUSE[chip], ActionEvent.ALT_MASK));
        pauseMenuItem[chip].setActionCommand(COMMAND_EMULATOR_PAUSE[chip]);
        pauseMenuItem[chip].addActionListener(this);
        runMenu.add(pauseMenuItem[chip]);

        //emulator step
        stepMenuItem[chip] = new JMenuItem("Step " + Constants.CHIP_LABEL[chip] + " emulator");
        stepMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_STEP[chip], ActionEvent.ALT_MASK));
        stepMenuItem[chip].setActionCommand(COMMAND_EMULATOR_STEP[chip]);
        stepMenuItem[chip].addActionListener(this);
        runMenu.add(stepMenuItem[chip]);

        //emulator stop
        stopMenuItem[chip] = new JMenuItem("Stop and reset " + Constants.CHIP_LABEL[chip] + " emulator");
        stopMenuItem[chip].setActionCommand(COMMAND_EMULATOR_STOP[chip]);
        stopMenuItem[chip].addActionListener(this);
        runMenu.add(stopMenuItem[chip]);

        runMenu.add(new JSeparator());

        //setup breakpoints
        breakpointMenuItem[chip] = new JMenuItem("Setup " + Constants.CHIP_LABEL[chip] + " breakpoints");
        breakpointMenuItem[chip].setActionCommand(COMMAND_SETUP_BREAKPOINTS[chip]);
        breakpointMenuItem[chip].addActionListener(this);
        runMenu.add(breakpointMenuItem[chip]);

        if (chip == Constants.CHIP_FR) {
            runMenu.add(new JSeparator());
        }
    }

    //Set up the components menu.
    JMenu componentsMenu = new JMenu("Components");
    componentsMenu.setMnemonic(KeyEvent.VK_O);
    menuBar.add(componentsMenu);

    for (int chip = 0; chip < 2; chip++) {
        //CPU state
        cpuStateMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " CPU State window");
        if (chip == Constants.CHIP_FR)
            cpuStateMenuItem[chip].setMnemonic(KEY_EVENT_CPUSTATE);
        cpuStateMenuItem[chip]
                .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_CPUSTATE, KEY_CHIP_MODIFIER[chip]));
        cpuStateMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CPUSTATE_WINDOW[chip]);
        cpuStateMenuItem[chip].addActionListener(this);
        componentsMenu.add(cpuStateMenuItem[chip]);

        //memory hex editor
        memoryHexEditorMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " Memory hex editor");
        if (chip == Constants.CHIP_FR)
            memoryHexEditorMenuItem[chip].setMnemonic(KEY_EVENT_MEMORY);
        memoryHexEditorMenuItem[chip]
                .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_MEMORY, KEY_CHIP_MODIFIER[chip]));
        memoryHexEditorMenuItem[chip].setActionCommand(COMMAND_TOGGLE_MEMORY_HEX_EDITOR[chip]);
        memoryHexEditorMenuItem[chip].addActionListener(this);
        componentsMenu.add(memoryHexEditorMenuItem[chip]);

        //Interrupt controller
        interruptControllerMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " interrupt controller");
        interruptControllerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_INTERRUPT_CONTROLLER_WINDOW[chip]);
        interruptControllerMenuItem[chip].addActionListener(this);
        componentsMenu.add(interruptControllerMenuItem[chip]);

        //Programmble timers
        programmableTimersMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " programmable timers");
        programmableTimersMenuItem[chip].setActionCommand(COMMAND_TOGGLE_PROGRAMMABLE_TIMERS_WINDOW[chip]);
        programmableTimersMenuItem[chip].addActionListener(this);
        componentsMenu.add(programmableTimersMenuItem[chip]);

        //Serial interface
        serialInterfacesMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " serial interfaces");
        serialInterfacesMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SERIAL_INTERFACES[chip]);
        serialInterfacesMenuItem[chip].addActionListener(this);
        componentsMenu.add(serialInterfacesMenuItem[chip]);

        // I/O
        ioPortsMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " I/O ports");
        ioPortsMenuItem[chip].setActionCommand(COMMAND_TOGGLE_IO_PORTS_WINDOW[chip]);
        ioPortsMenuItem[chip].addActionListener(this);
        componentsMenu.add(ioPortsMenuItem[chip]);

        //Serial devices
        serialDevicesMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " serial devices");
        serialDevicesMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SERIAL_DEVICES[chip]);
        serialDevicesMenuItem[chip].addActionListener(this);
        componentsMenu.add(serialDevicesMenuItem[chip]);

        componentsMenu.add(new JSeparator());
    }

    //screen emulator: FR80 only
    screenEmulatorMenuItem = new JCheckBoxMenuItem("Screen emulator (FR only)");
    screenEmulatorMenuItem.setMnemonic(KEY_EVENT_SCREEN);
    screenEmulatorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_SCREEN, ActionEvent.ALT_MASK));
    screenEmulatorMenuItem.setActionCommand(COMMAND_TOGGLE_SCREEN_EMULATOR);
    screenEmulatorMenuItem.addActionListener(this);
    componentsMenu.add(screenEmulatorMenuItem);

    //Component 4006: FR80 only
    component4006MenuItem = new JCheckBoxMenuItem("Component 4006 window (FR only)");
    component4006MenuItem.setMnemonic(KeyEvent.VK_4);
    component4006MenuItem.setActionCommand(COMMAND_TOGGLE_COMPONENT_4006_WINDOW);
    component4006MenuItem.addActionListener(this);
    componentsMenu.add(component4006MenuItem);

    componentsMenu.add(new JSeparator());

    //A/D converter: TX19 only for now
    adConverterMenuItem[Constants.CHIP_TX] = new JCheckBoxMenuItem(
            Constants.CHIP_LABEL[Constants.CHIP_TX] + " A/D converter (TX only)");
    adConverterMenuItem[Constants.CHIP_TX].setActionCommand(COMMAND_TOGGLE_AD_CONVERTER[Constants.CHIP_TX]);
    adConverterMenuItem[Constants.CHIP_TX].addActionListener(this);
    componentsMenu.add(adConverterMenuItem[Constants.CHIP_TX]);

    //Front panel: TX19 only
    frontPanelMenuItem = new JCheckBoxMenuItem("Front panel (TX only)");
    frontPanelMenuItem.setActionCommand(COMMAND_TOGGLE_FRONT_PANEL);
    frontPanelMenuItem.addActionListener(this);
    componentsMenu.add(frontPanelMenuItem);

    //Set up the trace menu.
    JMenu traceMenu = new JMenu("Trace");
    traceMenu.setMnemonic(KeyEvent.VK_C);
    menuBar.add(traceMenu);

    for (int chip = 0; chip < 2; chip++) {
        //memory activity viewer
        memoryActivityViewerMenuItem[chip] = new JCheckBoxMenuItem(
                Constants.CHIP_LABEL[chip] + " Memory activity viewer");
        memoryActivityViewerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_MEMORY_ACTIVITY_VIEWER[chip]);
        memoryActivityViewerMenuItem[chip].addActionListener(this);
        traceMenu.add(memoryActivityViewerMenuItem[chip]);

        //disassembly
        disassemblyMenuItem[chip] = new JCheckBoxMenuItem(
                "Real-time " + Constants.CHIP_LABEL[chip] + " disassembly log");
        if (chip == Constants.CHIP_FR)
            disassemblyMenuItem[chip].setMnemonic(KEY_EVENT_REALTIME_DISASSEMBLY);
        disassemblyMenuItem[chip].setAccelerator(
                KeyStroke.getKeyStroke(KEY_EVENT_REALTIME_DISASSEMBLY, KEY_CHIP_MODIFIER[chip]));
        disassemblyMenuItem[chip].setActionCommand(COMMAND_TOGGLE_DISASSEMBLY_WINDOW[chip]);
        disassemblyMenuItem[chip].addActionListener(this);
        traceMenu.add(disassemblyMenuItem[chip]);

        //Custom logger
        customMemoryRangeLoggerMenuItem[chip] = new JCheckBoxMenuItem(
                "Custom " + Constants.CHIP_LABEL[chip] + " logger window");
        customMemoryRangeLoggerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CUSTOM_LOGGER_WINDOW[chip]);
        customMemoryRangeLoggerMenuItem[chip].addActionListener(this);
        traceMenu.add(customMemoryRangeLoggerMenuItem[chip]);

        //Call Stack logger
        callStackMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " Call stack logger");
        callStackMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CALL_STACK_WINDOW[chip]);
        callStackMenuItem[chip].addActionListener(this);
        traceMenu.add(callStackMenuItem[chip]);

        //ITRON Object
        iTronObjectMenuItem[chip] = new JCheckBoxMenuItem("ITRON " + Constants.CHIP_LABEL[chip] + " Objects");
        iTronObjectMenuItem[chip].setActionCommand(COMMAND_TOGGLE_ITRON_OBJECT_WINDOW[chip]);
        iTronObjectMenuItem[chip].addActionListener(this);
        traceMenu.add(iTronObjectMenuItem[chip]);

        //ITRON Return Stack
        iTronReturnStackMenuItem[chip] = new JCheckBoxMenuItem(
                "ITRON " + Constants.CHIP_LABEL[chip] + " Return stack");
        iTronReturnStackMenuItem[chip].setActionCommand(COMMAND_TOGGLE_ITRON_RETURN_STACK_WINDOW[chip]);
        iTronReturnStackMenuItem[chip].addActionListener(this);
        traceMenu.add(iTronReturnStackMenuItem[chip]);

        traceMenu.add(new JSeparator());
    }

    //Set up the source menu.
    JMenu sourceMenu = new JMenu("Source");
    sourceMenu.setMnemonic(KEY_EVENT_SCREEN);
    menuBar.add(sourceMenu);

    // FR syscall symbols
    generateSysSymbolsMenuItem = new JMenuItem(
            "Generate " + Constants.CHIP_LABEL[Constants.CHIP_FR] + " system call symbols");
    generateSysSymbolsMenuItem.setActionCommand(COMMAND_GENERATE_SYS_SYMBOLS);
    generateSysSymbolsMenuItem.addActionListener(this);
    sourceMenu.add(generateSysSymbolsMenuItem);

    for (int chip = 0; chip < 2; chip++) {

        sourceMenu.add(new JSeparator());

        //analyse / disassemble
        analyseMenuItem[chip] = new JMenuItem("Analyse / Disassemble " + Constants.CHIP_LABEL[chip] + " code");
        analyseMenuItem[chip].setActionCommand(COMMAND_ANALYSE_DISASSEMBLE[chip]);
        analyseMenuItem[chip].addActionListener(this);
        sourceMenu.add(analyseMenuItem[chip]);

        sourceMenu.add(new JSeparator());

        //code structure
        codeStructureMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " code structure");
        codeStructureMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CODE_STRUCTURE_WINDOW[chip]);
        codeStructureMenuItem[chip].addActionListener(this);
        sourceMenu.add(codeStructureMenuItem[chip]);

        //source code
        sourceCodeMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " source code");
        if (chip == Constants.CHIP_FR)
            sourceCodeMenuItem[chip].setMnemonic(KEY_EVENT_SOURCE);
        sourceCodeMenuItem[chip]
                .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_SOURCE, KEY_CHIP_MODIFIER[chip]));
        sourceCodeMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SOURCE_CODE_WINDOW[chip]);
        sourceCodeMenuItem[chip].addActionListener(this);
        sourceMenu.add(sourceCodeMenuItem[chip]);

        if (chip == Constants.CHIP_FR) {
            sourceMenu.add(new JSeparator());
        }
    }

    //Set up the tools menu.
    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    menuBar.add(toolsMenu);

    for (int chip = 0; chip < 2; chip++) {
        // save/load memory area
        saveLoadMemoryMenuItem[chip] = new JMenuItem(
                "Save/Load " + Constants.CHIP_LABEL[chip] + " memory area");
        saveLoadMemoryMenuItem[chip].setActionCommand(COMMAND_SAVE_LOAD_MEMORY[chip]);
        saveLoadMemoryMenuItem[chip].addActionListener(this);
        toolsMenu.add(saveLoadMemoryMenuItem[chip]);

        //chip options
        chipOptionsMenuItem[chip] = new JMenuItem(Constants.CHIP_LABEL[chip] + " options");
        chipOptionsMenuItem[chip].setActionCommand(COMMAND_CHIP_OPTIONS[chip]);
        chipOptionsMenuItem[chip].addActionListener(this);
        toolsMenu.add(chipOptionsMenuItem[chip]);

        toolsMenu.add(new JSeparator());

    }

    //disassembly options
    uiOptionsMenuItem = new JMenuItem("Preferences");
    uiOptionsMenuItem.setActionCommand(COMMAND_UI_OPTIONS);
    uiOptionsMenuItem.addActionListener(this);
    toolsMenu.add(uiOptionsMenuItem);

    //Set up the help menu.
    JMenu helpMenu = new JMenu("?");
    menuBar.add(helpMenu);

    //about
    JMenuItem aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.setActionCommand(COMMAND_ABOUT);
    aboutMenuItem.addActionListener(this);
    helpMenu.add(aboutMenuItem);

    //        JMenuItem testMenuItem = new JMenuItem("Test");
    //        testMenuItem.setActionCommand(COMMAND_TEST);
    //        testMenuItem.addActionListener(this);
    //        helpMenu.add(testMenuItem);

    // Global "Keep in sync" setting
    menuBar.add(Box.createHorizontalGlue());
    final JCheckBox syncEmulators = new JCheckBox("Keep emulators in sync");
    syncEmulators.setSelected(prefs.isSyncPlay());
    framework.getMasterClock().setSyncPlay(prefs.isSyncPlay());
    syncEmulators.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            prefs.setSyncPlay(syncEmulators.isSelected());
            framework.getMasterClock().setSyncPlay(syncEmulators.isSelected());
        }
    });
    menuBar.add(syncEmulators);
    return menuBar;
}

From source file:edu.ku.brc.af.ui.forms.FormViewObj.java

/**
 * Shows Parent Form's Context Menu./*  ww  w  .jav a  2s . c  o  m*/
 * @param e the mouse event
 */
protected void showContextMenu(MouseEvent e) {
    if (e.isPopupTrigger() && mvParent != null && mvParent.isTopLevel() && isEditing) {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("CONFIG_CARRY_FORWARD_MENU"));
        menuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ex) {
                configureCarryForward();
            }
        });
        popup.add(menuItem);

        JCheckBoxMenuItem chkMI = new JCheckBoxMenuItem(
                UIRegistry.getResourceString("CARRY_FORWARD_CHECKED_MENU"));
        chkMI.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ex) {
                toggleCarryForward();
            }
        });
        chkMI.setSelected(isCarryForwardConfgured() && isDoCarryForward());
        chkMI.setEnabled(isCarryForwardConfgured());
        popup.add(chkMI);

        popup.addSeparator();
        chkMI = new JCheckBoxMenuItem(UIRegistry.getAction(AUTO_NUM));
        /*chkMI.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ex)
        {
            toggleAutoNumberOnOffState();
        }
        });*/
        chkMI.setSelected(isAutoNumberOn);
        popup.add(chkMI);

        popup.show(e.getComponent(), e.getX(), e.getY());
    }
}

From source file:net.sf.jabref.gui.JabRefFrame.java

private void fillMenu() {
    mb.setBorder(null);//from   ww w .ja va2  s  .  c om
    JMenu file = JabRefFrame.subMenu(Localization.menuTitle("File"));
    JMenu edit = JabRefFrame.subMenu(Localization.menuTitle("Edit"));
    JMenu search = JabRefFrame.subMenu(Localization.menuTitle("Search"));
    JMenu groups = JabRefFrame.subMenu(Localization.menuTitle("Groups"));
    JMenu bibtex = JabRefFrame.subMenu("&BibTeX");
    JMenu quality = JabRefFrame.subMenu(Localization.menuTitle("Quality"));
    JMenu view = JabRefFrame.subMenu(Localization.menuTitle("View"));
    JMenu tools = JabRefFrame.subMenu(Localization.menuTitle("Tools"));
    JMenu options = JabRefFrame.subMenu(Localization.menuTitle("Options"));
    JMenu newSpec = JabRefFrame.subMenu(Localization.menuTitle("New entry by type..."));
    JMenu helpMenu = JabRefFrame.subMenu(Localization.menuTitle("Help"));

    file.add(newBibtexDatabaseAction);
    file.add(newBiblatexDatabaseAction);
    file.add(getOpenDatabaseAction());
    file.add(mergeDatabaseAction);
    file.add(save);
    file.add(saveAs);
    file.add(saveAll);
    file.add(saveSelectedAs);
    file.add(saveSelectedAsPlain);
    file.addSeparator();
    file.add(importNew);
    file.add(importCurrent);
    file.add(exportAll);
    file.add(exportSelected);
    file.addSeparator();
    file.add(dbConnect);
    file.add(dbImport);
    file.add(dbExport);

    file.addSeparator();
    file.add(databaseProperties);
    file.add(editModeAction);
    file.addSeparator();

    file.add(fileHistory);
    file.addSeparator();
    file.add(closeDatabaseAction);
    file.add(quit);
    mb.add(file);

    edit.add(undo);
    edit.add(redo);

    edit.addSeparator();

    edit.add(cut);
    edit.add(copy);
    edit.add(paste);

    edit.addSeparator();

    edit.add(copyKey);
    edit.add(copyCiteKey);
    edit.add(copyKeyAndTitle);
    edit.add(exportToClipboard);
    edit.add(sendAsEmail);

    edit.addSeparator();
    edit.add(mark);
    JMenu markSpecific = JabRefFrame.subMenu(Localization.menuTitle("Mark specific color"));
    for (int i = 0; i < EntryMarker.MAX_MARKING_LEVEL; i++) {
        markSpecific.add(new MarkEntriesAction(this, i).getMenuItem());
    }
    edit.add(markSpecific);
    edit.add(unmark);
    edit.add(unmarkAll);
    edit.addSeparator();
    if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) {
        JMenu m;
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) {
            m = new JMenu();
            RightClickMenu.populateSpecialFieldMenu(m, Rank.getInstance(), this);
            edit.add(m);
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) {
            edit.add(toggleRelevance);
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) {
            edit.add(toggleQualityAssured);
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) {
            m = new JMenu();
            RightClickMenu.populateSpecialFieldMenu(m, Priority.getInstance(), this);
            edit.add(m);
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) {
            edit.add(togglePrinted);
        }
        if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) {
            m = new JMenu();
            RightClickMenu.populateSpecialFieldMenu(m, ReadStatus.getInstance(), this);
            edit.add(m);
        }
        edit.addSeparator();
    }

    edit.add(getManageKeywords());
    edit.add(getMassSetField());
    edit.addSeparator();
    edit.add(selectAll);
    mb.add(edit);

    search.add(normalSearch);
    search.add(replaceAll);
    search.addSeparator();
    search.add(new JCheckBoxMenuItem(generalFetcher.getAction()));
    if (prefs.getBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE)) {
        sidePaneManager.register(generalFetcher.getTitle(), generalFetcher);
        sidePaneManager.show(generalFetcher.getTitle());
    }
    mb.add(search);

    groups.add(new JCheckBoxMenuItem(toggleGroups));
    groups.addSeparator();
    groups.add(addToGroup);
    groups.add(removeFromGroup);
    groups.add(moveToGroup);
    groups.addSeparator();
    JRadioButtonMenuItem toggleHighlightAnyItem = new JRadioButtonMenuItem(toggleHighlightAny);
    groups.add(toggleHighlightAnyItem);
    JRadioButtonMenuItem toggleHighlightAllItem = new JRadioButtonMenuItem(toggleHighlightAll);
    groups.add(toggleHighlightAllItem);
    JRadioButtonMenuItem toggleHighlightDisableItem = new JRadioButtonMenuItem(toggleHighlightDisable);
    groups.add(toggleHighlightDisableItem);
    ButtonGroup highlightButtonGroup = new ButtonGroup();
    highlightButtonGroup.add(toggleHighlightDisableItem);
    highlightButtonGroup.add(toggleHighlightAnyItem);
    highlightButtonGroup.add(toggleHighlightAllItem);

    HighlightMatchingGroupPreferences highlightMatchingGroupPreferences = new HighlightMatchingGroupPreferences(
            Globals.prefs);
    if (highlightMatchingGroupPreferences.isAll()) {
        toggleHighlightAllItem.setSelected(true);
    } else if (highlightMatchingGroupPreferences.isAny()) {
        toggleHighlightAnyItem.setSelected(true);
    } else {
        toggleHighlightDisableItem.setSelected(true);
    }

    mb.add(groups);

    view.add(getBackAction());
    view.add(getForwardAction());
    view.add(focusTable);
    view.add(nextTab);
    view.add(prevTab);
    view.add(sortTabs);
    view.addSeparator();
    view.add(increaseFontSize);
    view.add(decreseFontSize);
    view.addSeparator();
    view.add(new JCheckBoxMenuItem(toggleToolbar));
    view.add(new JCheckBoxMenuItem(enableToggle(generalFetcher.getAction())));
    view.add(new JCheckBoxMenuItem(toggleGroups));
    view.add(new JCheckBoxMenuItem(togglePreview));
    view.add(getSwitchPreviewAction());

    mb.add(view);

    bibtex.add(newEntryAction);

    for (NewEntryAction a : newSpecificEntryAction) {
        newSpec.add(a);
    }
    bibtex.add(newSpec);

    bibtex.add(plainTextImport);
    bibtex.addSeparator();
    bibtex.add(editEntry);
    bibtex.add(editPreamble);
    bibtex.add(editStrings);
    bibtex.addSeparator();
    bibtex.add(customizeAction);
    bibtex.addSeparator();
    bibtex.add(deleteEntry);
    mb.add(bibtex);

    quality.add(dupliCheck);
    quality.add(mergeEntries);
    quality.addSeparator();
    quality.add(resolveDuplicateKeys);
    quality.add(checkIntegrity);
    quality.add(cleanupEntries);
    quality.add(makeKeyAction);
    quality.addSeparator();
    quality.add(autoSetFile);
    quality.add(findUnlinkedFiles);
    quality.add(autoLinkFile);
    quality.add(downloadFullText);
    mb.add(quality);

    tools.add(newSubDatabaseAction);
    tools.add(writeXmpAction);
    OpenOfficePanel otp = OpenOfficePanel.getInstance();
    otp.init(this, sidePaneManager);
    tools.add(otp.getMenuItem());
    tools.add(pushExternalButton.getMenuAction());
    tools.addSeparator();
    tools.add(openFolder);
    tools.add(openFile);
    tools.add(openUrl);
    tools.add(openConsole);
    tools.addSeparator();
    tools.add(abbreviateIso);
    tools.add(abbreviateMedline);
    tools.add(unabbreviate);
    mb.add(tools);

    options.add(showPrefs);

    AbstractAction genFieldsCustomization = new GenFieldsCustomizationAction();
    options.add(genFieldsCustomization);
    options.add(customExpAction);
    options.add(customImpAction);
    options.add(customFileTypesAction);
    options.add(manageJournals);
    options.add(manageSelectors);
    options.add(selectKeys);
    mb.add(options);

    helpMenu.add(help);
    helpMenu.add(openForumAction);
    helpMenu.addSeparator();
    helpMenu.add(errorConsole);
    helpMenu.addSeparator();
    helpMenu.add(forkMeOnGitHubAction);
    helpMenu.add(donationAction);
    helpMenu.addSeparator();
    helpMenu.add(new SearchForUpdateAction());
    helpMenu.add(about);
    mb.add(helpMenu);

    createDisabledIconsForMenuEntries(mb);
}

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

void constructMenu() {
    JMenuBar mb;// w  ww  .  j a  v  a2s  .  com
    mb = new JMenuBar();
    setJMenuBar(mb);

    final CallsFromArgBuilder2XSB calls2XSB = new CallsFromArgBuilder2XSB();

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

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

            //the file is loaded
            GraphAnalysis();

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

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

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

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

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

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

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

            ArgumentWriter();

            drawArguments();

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

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

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

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

    fileMenu.addSeparator();

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

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

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

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

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

From source file:com.SE.myPlayer.MusicPlayerGUI.java

private void refereshColumnPopUp() {
        finalString = sd.getColNames();/*from w  w  w.ja  v  a2  s  .com*/

        JCheckBoxMenuItem menuItems;
        columnShow_PopUp.removeAll();
        for (int i = 0; i < finalString.size() - 1; i += 2) {
            if (!finalString.get(i).equals("Location") && !finalString.get(i).equals("Name")) {
                menuItems = new JCheckBoxMenuItem(new ColShowAction(finalString.get(i)));
                if (finalString.get(i + 1).equals("1")) {
                    menuItems.setState(true);
                }
                columnShow_PopUp.add(menuItems);
            }
        }
    }