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() 

Source Link

Document

Creates an initially unselected check box menu item with no set text or icon.

Usage

From source file:org.gtdfree.GTDFree.java

/**
 * This method initializes jMenu   /*from  w  ww  . j  a  v  a  2s  . c om*/
 *    
 * @return javax.swing.JMenu   
 */
private JMenu getHelpMenu() {
    if (helpMenu == null) {
        helpMenu = new JMenu();
        helpMenu.setText(Messages.getString("GTDFree.Help")); //$NON-NLS-1$

        JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.Help.Home")); //$NON-NLS-1$
        jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser));
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                URI uri;
                try {
                    uri = new URI(getEngine().getConfiguration().getProperty("home.url", //$NON-NLS-1$
                            "http://gtd-free.sourceforge.net")); //$NON-NLS-1$
                    Desktop.getDesktop().browse(uri);
                } catch (Exception e1) {
                    Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$
                }
            }
        });
        helpMenu.add(jmi);

        jmi = new JMenuItem(Messages.getString("GTDFree.Help.Manuals")); //$NON-NLS-1$
        jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser));
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                URI uri;
                try {
                    uri = new URI(getEngine().getConfiguration().getProperty("manuals.url", //$NON-NLS-1$
                            "http://gtd-free.sourceforge.net/manuals.html")); //$NON-NLS-1$ //$NON-NLS-3$
                    Desktop.getDesktop().browse(uri);
                } catch (Exception e1) {
                    Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$
                }
            }
        });
        helpMenu.add(jmi);

        jmi = new JMenuItem(getActionMap().get("importDialog")); //$NON-NLS-1$
        helpMenu.add(jmi);

        helpMenu.add(new JSeparator());

        jmi = new JMenuItem();
        jmi.setText(Messages.getString("GTDFree.Check")); //$NON-NLS-1$
        jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_update));
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                new Thread() {
                    @Override
                    public void run() {
                        checkForUpdates(true);
                    }
                }.start();
            }
        });
        helpMenu.add(jmi);

        JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem();
        jcbmi.setText(Messages.getString("GTDFree.CheckAtStartup")); //$NON-NLS-1$
        try {
            getEngine().getGlobalProperties().connectBooleanProperty(GlobalProperties.CHECK_FOR_UPDATE_AT_START,
                    jcbmi, "selected", "isSelected", "setSelected", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        } catch (Exception e1) {
            logger.debug("Internal error.", e1); //$NON-NLS-1$
        }
        helpMenu.add(jcbmi);

        helpMenu.add(new JSeparator());

        jmi = new JMenuItem();
        jmi.setText(Messages.getString("GTDFree.Help.Mon")); //$NON-NLS-1$
        jmi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                getMonitor().getDialog().setVisible(true);
            }
        });
        helpMenu.add(jmi);

        helpMenu.add(new JSeparator());

        helpMenu.add(getAboutMenuItem());
    }
    return helpMenu;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.PopupMenu.java

/**
 * Initializes the menu items with the given actions.
 *//*from ww  w  .  j  ava2  s  . c o m*/
private void initComponents() {
    IconManager icons = IconManager.getInstance();
    resetPassword = new JMenuItem(controller.getAction(DataBrowserControl.RESET_PASSWORD));
    ActivatedUserAction a = (ActivatedUserAction) controller.getAction(DataBrowserControl.USER_ACTIVATED);
    activatedUser = new JCheckBoxMenuItem();
    ImageDisplay node = model.getBrowser().getLastSelectedDisplay();
    boolean value = false;
    if (node != null) {
        Object o = node.getHierarchyObject();
        if (o instanceof ExperimenterData) {
            ExperimenterData exp = (ExperimenterData) o;
            ExperimenterData loggedIn = model.getCurrentUser();
            value = exp.getId() == loggedIn.getId();
            activatedUser.setSelected(exp.isActive());
            if (exp.isActive()) {
                activatedUser.setIcon(ActivatedUserAction.ACTIVATED_ICON);
            } else {
                activatedUser.setIcon(ActivatedUserAction.NOT_ACTIVATED_ICON);
            }
            activatedUser.setEnabled(!value && !model.isSystemUser(exp.getId()));
        }
        if (!value)
            activatedUser.addItemListener(new ItemListener() {

                public void itemStateChanged(ItemEvent e) {
                    controller.activateUser();
                }
            });
    } else
        activatedUser.setEnabled(false);
    activatedUser.setAction(a);
    tagElement = new JMenuItem(controller.getAction(DataBrowserControl.TAG));
    newExperimentElement = new JMenuItem(controller.getAction(DataBrowserControl.NEW_EXPERIMENT));

    view = new JMenuItem(controller.getAction(DataBrowserControl.VIEW));
    copyElement = new JMenuItem(controller.getAction(DataBrowserControl.COPY_OBJECT));
    cutElement = new JMenuItem(controller.getAction(DataBrowserControl.CUT_OBJECT));
    pasteElement = new JMenuItem(controller.getAction(DataBrowserControl.PASTE_OBJECT));
    removeElement = new JMenuItem(controller.getAction(DataBrowserControl.REMOVE_OBJECT));
    pasteRndSettings = new JMenuItem(controller.getAction(DataBrowserControl.PASTE_RND_SETTINGS));
    resetRndSettings = new JMenuItem(controller.getAction(DataBrowserControl.RESET_RND_SETTINGS));
    copyRndSettings = new JMenuItem(controller.getAction(DataBrowserControl.COPY_RND_SETTINGS));
    setMinMaxSettings = new JMenuItem(controller.getAction(DataBrowserControl.SET_MIN_MAX_SETTINGS));
    setOwnerRndSettings = new JMenuItem(controller.getAction(DataBrowserControl.SET_OWNER_RND_SETTINGS));
    openWithMenu = new JMenu("Open with");
    openWithMenu.setIcon(icons.getIcon(IconManager.VIEWER));
    if (model.getType() == DataBrowserModel.SEARCH) {
        copyElement.setEnabled(false);
        pasteElement.setEnabled(false);
        cutElement.setEnabled(false);
    }
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the view menu.
 * //from   w ww  .  ja v  a  2s. c  om
 * @param pref The user preferences.
 * @return The controls sub-menu.
 */
private JMenu createViewMenu(ViewerPreferences pref) {
    JMenu menu = new JMenu("Display");
    menu.setMnemonic(KeyEvent.VK_V);
    unitBarItem = new JCheckBoxMenuItem();
    unitBarItem.setSelected(model.isUnitBar());
    unitBarItem.setAction(controller.getAction(ImViewerControl.UNIT_BAR));
    menu.add(unitBarItem);
    menu.add(createScaleBarLengthSubMenu(pref));
    menu.add(createScaleBarColorSubMenu(pref));
    menu.add(new JSeparator(JSeparator.HORIZONTAL));
    menu.add(createBackgroundColorSubMenu(pref));
    //menu.add(new JSeparator(JSeparator.HORIZONTAL));
    return menu;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the controls menu.
 * //  w  w  w .j  av  a  2 s.c  om
 * @param pref The user preferences.
 * @return The controls sub-menu.
 */
private JMenu createControlsMenu(ViewerPreferences pref) {
    JMenu menu = new JMenu("Controls");
    menu.setMnemonic(KeyEvent.VK_C);
    ViewerAction action = controller.getAction(ImViewerControl.RENDERER);

    rndItem = new JCheckBoxMenuItem();
    rndItem.setSelected(isRendererShown());
    rndItem.setAction(action);
    rndItem.setText(action.getName());
    if (pref != null)
        rndItem.setSelected(pref.isRenderer());
    //menu.add(rndItem);

    action = controller.getAction(ImViewerControl.METADATA);
    metadataItem = new JCheckBoxMenuItem();
    metadataItem.setSelected(isRendererShown());
    metadataItem.setAction(action);
    metadataItem.setText(action.getName());
    if (pref != null)
        metadataItem.setSelected(pref.isRenderer());
    //menu.add(metadataItem);

    action = controller.getAction(ImViewerControl.HISTORY);
    historyItem = new JCheckBoxMenuItem();
    historyItem.setSelected(isHistoryShown());
    historyItem.setAction(action);
    historyItem.setText(action.getName());
    if (pref != null)
        historyItem.setSelected(pref.isHistory());
    //menu.add(historyItem);

    action = controller.getAction(ImViewerControl.MOVIE);
    JMenuItem item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.LENS);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.MEASUREMENT_TOOL);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    menu.add(new JSeparator(JSeparator.HORIZONTAL));
    //Color model
    colorModelGroup = new ButtonGroup();
    action = controller.getAction(ImViewerControl.GREY_SCALE_MODEL);
    item = new JCheckBoxMenuItem();
    String cm = model.getColorModel();
    item.setSelected(cm.equals(ImViewer.GREY_SCALE_MODEL));
    item.setAction(action);
    colorModelGroup.add(item);
    menu.add(item);
    action = controller.getAction(ImViewerControl.RGB_MODEL);
    item = new JCheckBoxMenuItem();
    item.setAction(action);
    item.setSelected(cm.equals(ImViewer.RGB_MODEL));
    colorModelGroup.add(item);
    menu.add(item);

    menu.add(new JSeparator());
    action = controller.getAction(ImViewerControl.CHANNELS_ON);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.CHANNELS_OFF);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);

    menu.add(new JSeparator());
    action = controller.getAction(ImViewerControl.SAVE);
    item = new JMenuItem(action);
    item.setText(action.getName());
    menu.add(item);
    action = controller.getAction(ImViewerControl.PREFERENCES);
    item = new JMenuItem(action);
    item.setText(action.getName());
    //menu.add(item);
    return menu;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Helper method to create the Zoom menu. 
 * // ww w .ja v a2s.  co m
 * @param pref  The user preferences.
 * @param full  Pass <code>true</code> to create a full menu, 
 *             <code>false</code> to create a partial menu.
 * @return See above.
 */
private JMenu createZoomMenu(ViewerPreferences pref, boolean full) {
    ViewerAction action;
    JCheckBoxMenuItem item;
    if (model.isBigImage()) {
        action = controller.getAction(ImViewerControl.ZOOM_100);
        item = new JCheckBoxMenuItem();
        item.setAction(action);
        zoomMenu.add(item);
        action = controller.getAction(ImViewerControl.ZOOM_125);
        item = new JCheckBoxMenuItem();
        item.setAction(action);
        zoomMenu.add(item);
        action = controller.getAction(ImViewerControl.ZOOM_150);
        item = new JCheckBoxMenuItem();
        item.setAction(action);
        zoomMenu.add(item);
        action = controller.getAction(ImViewerControl.ZOOM_175);
        item = new JCheckBoxMenuItem();
        item.setAction(action);
        zoomMenu.add(item);
        return zoomMenu;
    }
    action = controller.getAction(ImViewerControl.ZOOM_25);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_50);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_75);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_100);
    item = new JCheckBoxMenuItem();
    item.setAction(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    //if (full) {
    action = controller.getAction(ImViewerControl.ZOOM_125);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_150);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_175);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_200);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_225);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_250);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_275);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    action = controller.getAction(ImViewerControl.ZOOM_300);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    //}

    action = controller.getAction(ImViewerControl.ZOOM_FIT_TO_WINDOW);
    item = new JCheckBoxMenuItem(action);
    zoomMenu.add(item);
    zoomingGroup.add(item);
    int index = ZoomAction.DEFAULT_ZOOM_INDEX;
    double factor = ZoomAction.DEFAULT_ZOOM_FACTOR;
    if (pref != null) {
        if (pref.isFieldSelected(ViewerPreferences.ZOOM_FACTOR)) {
            index = pref.getZoomIndex();
            factor = ZoomAction.getZoomFactor(index);
        }
    }
    setZoomFactor(factor, index);

    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.ZOOM_GRID_25));
    zoomGridMenu.add(item);
    zoomingGridGroup.add(item);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.ZOOM_GRID_50));
    zoomGridMenu.add(item);
    zoomingGridGroup.add(item);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.ZOOM_GRID_75));
    zoomGridMenu.add(item);
    zoomingGridGroup.add(item);
    item = new JCheckBoxMenuItem(controller.getAction(ImViewerControl.ZOOM_GRID_100));
    zoomGridMenu.add(item);
    zoomingGridGroup.add(item);
    setGridMagnificationFactor(ZoomGridAction.DEFAULT_ZOOM_FACTOR);
    return zoomMenu;
}

From source file:org.parosproxy.paros.extension.state.ExtensionState.java

/**
 * This method initializes menuViewImage   
 *    //from w w  w.j a  v a  2  s . co m
 * @return javax.swing.JCheckBoxMenuItem   
 */
private JCheckBoxMenuItem getMenuSessionTrackingEnable() {
    if (menuSessionTrackingEnable == null) {
        menuSessionTrackingEnable = new JCheckBoxMenuItem();
        menuSessionTrackingEnable.setText(Constant.messages.getString("menu.edit.enableTracking")); // ZAP: i18n
        getMenuResetSessionState().setEnabled(menuSessionTrackingEnable.isSelected());

        menuSessionTrackingEnable.addItemListener(new java.awt.event.ItemListener() {

            @Override
            public void itemStateChanged(java.awt.event.ItemEvent e) {

                getModel().getOptionsParam().getConnectionParam()
                        .setHttpStateEnabled(menuSessionTrackingEnable.isEnabled());
                getMenuResetSessionState().setEnabled(menuSessionTrackingEnable.isSelected());
                resetSessionState();
            }
        });

    }
    return menuSessionTrackingEnable;
}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java

protected JMenuItem createComponent(final String tagName) {
    if (RADIO_MENUITEM.equalsIgnoreCase(tagName)) {
        return new JRadioButtonMenuItem();
    } else if (CHECKBOX_MENUITEM.equalsIgnoreCase(tagName)) {
        return new JCheckBoxMenuItem();
    } else {/*from ww w . j a v a2 s  . c o  m*/
        return new JMenuItem();
    }
}