Example usage for javax.swing JMenuItem setSelected

List of usage examples for javax.swing JMenuItem setSelected

Introduction

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

Prototype

public void setSelected(boolean b) 

Source Link

Document

Sets the state of the button.

Usage

From source file:org.yccheok.jstock.gui.JStock.java

private void jMenu9MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu9MenuSelected
    this.jMenu9.removeAll();
    final java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames();
    final String currentWatchlistName = this.getJStockOptions().getWatchlistName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String watchlistName : watchlistNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) this.jMenu9.add(new JRadioButtonMenuItem(watchlistName));
        buttonGroup.add(mi);/*from w  ww  .j a  v a  2s  .co m*/
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentWatchlistName)) {
                    JStock.this.selectActiveWatchlist(s);
                }
            }

        });
        mi.setSelected(watchlistName.equals(currentWatchlistName));
    }

    this.jMenu9.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultipleWatchlist..."),
            this.getImageIcon("/images/16x16/stock_timezone.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multipleWatchlists();
        }

    });
    this.jMenu9.add(mi);
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void jMenu8MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu8MenuSelected
    this.jMenu8.removeAll();
    final java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames();
    final String currentPortfolioName = this.getJStockOptions().getPortfolioName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String portfolioName : portfolioNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) jMenu8.add(new JRadioButtonMenuItem(portfolioName));
        buttonGroup.add(mi);/*w  ww  . ja va  2  s.  c o  m*/
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentPortfolioName)) {
                    MainFrame.this.selectActivePortfolio(s);
                }
            }

        });
        mi.setSelected(portfolioName.equals(currentPortfolioName));
    }

    jMenu8.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultiplePortolio..."),
            this.getImageIcon("/images/16x16/calc.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multiplePortfolios();
        }

    });
    jMenu8.add(mi);
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void jMenu9MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu9MenuSelected
    this.jMenu9.removeAll();
    final java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames();
    final String currentWatchlistName = this.getJStockOptions().getWatchlistName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String watchlistName : watchlistNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) this.jMenu9.add(new JRadioButtonMenuItem(watchlistName));
        buttonGroup.add(mi);/*from www.  j  a  va2  s  . com*/
        mi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentWatchlistName)) {
                    MainFrame.this.selectActiveWatchlist(s);
                }
            }

        });
        mi.setSelected(watchlistName.equals(currentWatchlistName));
    }

    this.jMenu9.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultipleWatchlist..."),
            this.getImageIcon("/images/16x16/stock_timezone.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multipleWatchlists();
        }

    });
    this.jMenu9.add(mi);
}

From source file:processing.app.Base.java

public void rebuildBoardsMenu() throws Exception {
    boardsCustomMenus = new LinkedList<>();

    // The first custom menu is the "Board" selection submenu
    JMenu boardMenu = new JMenu(tr("Board"));
    boardMenu.putClientProperty("removeOnWindowDeactivation", true);
    MenuScroller.setScrollerFor(boardMenu).setTopFixedCount(1);

    boardMenu.add(new JMenuItem(new AbstractAction(tr("Boards Manager...")) {
        public void actionPerformed(ActionEvent actionevent) {
            String filterText = "";
            String dropdownItem = "";
            if (actionevent instanceof Event) {
                filterText = ((Event) actionevent).getPayload().get("filterText").toString();
                dropdownItem = ((Event) actionevent).getPayload().get("dropdownItem").toString();
            }/*from w  w w . ja  va2  s  . com*/
            try {
                openBoardsManager(filterText, dropdownItem);
            } catch (Exception e) {
                //TODO show error
                e.printStackTrace();
            }
        }
    }));
    boardsCustomMenus.add(boardMenu);

    // If there are no platforms installed we are done
    if (BaseNoGui.packages.size() == 0)
        return;

    // Separate "Install boards..." command from installed boards
    boardMenu.add(new JSeparator());

    // Generate custom menus for all platforms
    Set<String> customMenusTitles = new LinkedHashSet<>();
    for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
        for (TargetPlatform targetPlatform : targetPackage.platforms()) {
            customMenusTitles.addAll(targetPlatform.getCustomMenus().values());
        }
    }
    for (String customMenuTitle : customMenusTitles) {
        JMenu customMenu = new JMenu(tr(customMenuTitle));
        customMenu.putClientProperty("removeOnWindowDeactivation", true);
        boardsCustomMenus.add(customMenu);
    }

    List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<>();

    ButtonGroup boardsButtonGroup = new ButtonGroup();
    Map<String, ButtonGroup> buttonGroupsMap = new HashMap<>();

    // Cycle through all packages
    boolean first = true;
    for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
        // For every package cycle through all platform
        for (TargetPlatform targetPlatform : targetPackage.platforms()) {

            // Add a separator from the previous platform
            if (!first)
                boardMenu.add(new JSeparator());
            first = false;

            // Add a title for each platform
            String platformLabel = targetPlatform.getPreferences().get("name");
            if (platformLabel != null && !targetPlatform.getBoards().isEmpty()) {
                JMenuItem menuLabel = new JMenuItem(tr(platformLabel));
                menuLabel.setEnabled(false);
                boardMenu.add(menuLabel);
            }

            // Cycle through all boards of this platform
            for (TargetBoard board : targetPlatform.getBoards().values()) {
                if (board.getPreferences().get("hide") != null)
                    continue;
                JMenuItem item = createBoardMenusAndCustomMenus(boardsCustomMenus, menuItemsToClickAfterStartup,
                        buttonGroupsMap, board, targetPlatform, targetPackage);
                boardMenu.add(item);
                boardsButtonGroup.add(item);
            }
        }
    }

    if (menuItemsToClickAfterStartup.isEmpty()) {
        menuItemsToClickAfterStartup.add(selectFirstEnabledMenuItem(boardMenu));
    }

    for (JMenuItem menuItemToClick : menuItemsToClickAfterStartup) {
        menuItemToClick.setSelected(true);
        menuItemToClick.getAction().actionPerformed(new ActionEvent(this, -1, ""));
    }
}

From source file:processing.app.Base.java

private void filterVisibilityOfSubsequentBoardMenus(List<JMenu> boardsCustomMenus, TargetBoard board,
        int fromIndex) {
    for (int i = fromIndex; i < boardsCustomMenus.size(); i++) {
        JMenu menu = boardsCustomMenus.get(i);
        for (int m = 0; m < menu.getItemCount(); m++) {
            JMenuItem menuItem = menu.getItem(m);
            menuItem.setVisible(menuItem.getAction().getValue("board").equals(board));
        }//  w  w w.j a va  2 s .  c o m
        menu.setVisible(ifThereAreVisibleItemsOn(menu));

        if (menu.isVisible()) {
            JMenuItem visibleSelectedOrFirstMenuItem = selectVisibleSelectedOrFirstMenuItem(menu);
            if (!visibleSelectedOrFirstMenuItem.isSelected()) {
                visibleSelectedOrFirstMenuItem.setSelected(true);
                visibleSelectedOrFirstMenuItem.getAction().actionPerformed(null);
            }
        }
    }
}

From source file:processing.app.Base.java

public void rebuildProgrammerMenu() {
    programmerMenus = new LinkedList<>();

    ButtonGroup group = new ButtonGroup();
    for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
        for (TargetPlatform targetPlatform : targetPackage.platforms()) {
            for (String programmer : targetPlatform.getProgrammers().keySet()) {
                String id = targetPackage.getId() + ":" + programmer;

                @SuppressWarnings("serial")
                AbstractAction action = new AbstractAction(
                        targetPlatform.getProgrammer(programmer).get("name")) {
                    public void actionPerformed(ActionEvent actionevent) {
                        PreferencesData.set("programmer", "" + getValue("id"));
                    }/*  w w  w .  ja  v  a  2s.  co m*/
                };
                action.putValue("id", id);
                JMenuItem item = new JRadioButtonMenuItem(action);
                if (PreferencesData.get("programmer").equals(id)) {
                    item.setSelected(true);
                }
                group.add(item);
                programmerMenus.add(item);
            }
        }
    }
}

From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java

public static void addExpansionMenu(JMenuBar menuBar) {

    ButtonGroup itemGroup = new ButtonGroup();

    // Create a menu
    JMenu menu = new JMenu("Expansion model");
    menuBar.add(menu);/*from   ww w  . j av a 2 s.  c o m*/

    // Create none item
    JMenuItem noneItem = new JRadioButtonMenuItem("None");
    noneItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("No expansion strategy selected.");
            expansionStrategy = null;
        }
    });
    itemGroup.add(noneItem);
    menu.add(noneItem);

    // Create spoke model item
    JMenuItem spokeItem = new JRadioButtonMenuItem("Spoke");
    spokeItem.setSelected(true);
    spokeItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Sets expansion statefy to Spoke.");
            expansionStrategy = new SpokeExpansion();
        }
    });
    itemGroup.add(spokeItem);
    menu.add(spokeItem);

    // Create an exit
    JMenuItem matrixItem = new JRadioButtonMenuItem("Matrix");
    matrixItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Sets expansion statefy to Matrix.");
            expansionStrategy = new MatrixExpansion();
        }
    });
    itemGroup.add(matrixItem);
    menu.add(matrixItem);
}

From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java

public static void addProcessorMenu(JMenuBar menuBar) {

    // Create a menu
    JMenu menu = new JMenu("Processing");
    menuBar.add(menu);/*from w w w  . j ava 2s  .co  m*/

    ButtonGroup itemGroup = new ButtonGroup();

    // Create none item
    JMenuItem noneItem = new JRadioButtonMenuItem("None");
    noneItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Disables post processing.");
            postProcessorStrategy = null;
        }
    });
    itemGroup.add(noneItem);
    menu.add(noneItem);

    // Create a clustering item
    JMenuItem clusteringInteractorItem = new JRadioButtonMenuItem("Clustering interactor pairs");
    clusteringInteractorItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            log.debug("Enables post processing: ClusterPerInteractorProcessor");
            postProcessorStrategy = new ClusterInteractorPairProcessor();
        }
    });
    itemGroup.add(clusteringInteractorItem);
    clusteringInteractorItem.setSelected(true);
    menu.add(clusteringInteractorItem);
}

From source file:sc.fiji.kappa.gui.KappaMenuBar.java

/**
 * Creates a menu-bar and adds menu items to it
 *//* w ww  . ja va2s  .  c om*/
public KappaMenuBar(Context context, KappaFrame frame) {
    context.inject(this);

    this.frame = frame;

    // File chooser for curve data
    FileNameExtensionFilter kappaFilter = new FileNameExtensionFilter("Kappa Files", "kapp");

    kappaLoad = new JFileChooser();
    kappaLoad.setFileFilter(kappaFilter);
    kappaLoad.setDialogTitle("Load Existing Curve Data");

    kappaSave = new JFileChooser();
    kappaSave.setFileFilter(kappaFilter);
    kappaSave.setDialogTitle("Save Curve Data");

    // Declares the file menu
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('F');

    /*
     * // Menu Items for file operations // Creates a new file chooser. Same native
     * image support as ImageJ since ImageJ // libraries are used. kappaOpen = new
     * JFileChooser(); FileNameExtensionFilter filter = new
     * FileNameExtensionFilter("Image Files", "tif", "tiff", "jpeg", "jpg", "bmp",
     * "fits", "pgm", "ppm", "pbm", "gif", "png", "dic", "dcm", "dicom", "lsm",
     * "avi"); kappaOpen.setFileFilter(filter);
     * 
     * JMenuItem openMenu = new JMenuItem("Open Image File");
     * openMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK));
     * openMenu.addActionListener(e -> { int returnVal =
     * kappaOpen.showOpenDialog(this.frame); if (returnVal ==
     * JFileChooser.APPROVE_OPTION) { openImageFile(kappaOpen.getSelectedFile()); }
     * }); fileMenu.add(openMenu);
     */

    JMenuItem openActiveMenu = new JMenuItem("Open Active Image");
    openActiveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, DEFAULT_MASK));
    openActiveMenu.addActionListener(e -> {
        openActiveImage(context);
    });
    fileMenu.add(openActiveMenu);
    fileMenu.addSeparator();

    JMenuItem importROIsAsCurvesMenu = new JMenuItem("Import ROIs as curves");
    importROIsAsCurvesMenu.addActionListener(e -> {
        importROIsAsCurves(context);
    });
    fileMenu.add(importROIsAsCurvesMenu);
    fileMenu.addSeparator();

    JMenuItem loadMenu = new JMenuItem("Load Curve Data");
    loadMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MASK));
    loadMenu.addActionListener(e -> {
        // Handle open button action.
        int returnVal = kappaLoad.showOpenDialog(this.frame);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = kappaLoad.getSelectedFile();
            loadCurveFile(file);
        }
    });
    fileMenu.add(loadMenu);

    JMenuItem saveMenu = new JMenuItem("Save Curve Data");
    saveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, DEFAULT_MASK));
    saveMenu.addActionListener(e -> {

        String dirPath = frame.getImageStack().getOriginalFileInfo().directory;
        if (dirPath != null) {
            String kappaPath = FilenameUtils
                    .removeExtension(frame.getImageStack().getOriginalFileInfo().fileName);
            kappaPath += ".kapp";
            File fullPath = new File(dirPath, kappaPath);
            kappaSave.setSelectedFile(fullPath);
        }

        // Handles save button action.
        int returnVal = kappaSave.showSaveDialog(this.frame);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            file = kappaSave.getSelectedFile();
            // Appends a .kapp
            if (!file.getPath().toLowerCase().endsWith(".kapp")) {
                file = new File(file.getPath() + ".kapp");
            }
            saveCurveFile(file);
        }
    });
    fileMenu.add(saveMenu);

    this.add(fileMenu);

    // Menu Items for all the tools
    JMenu toolMenu = new JMenu("Tools");
    for (int i = 0; i < ToolPanel.NO_TOOLS; i++) {
        toolMenuItems[i] = new JMenuItem(ToolPanel.TOOL_MENU_NAMES[i]);
        toolMenuItems[i].setEnabled(false);
        toolMenuItems[i].setAccelerator(KeyStroke.getKeyStroke(ToolPanel.TOOL_MNEMONICS[i], 0));
        final int j = i;
        toolMenuItems[i].addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent event) {
                frame.getToolPanel().setSelected(j, true);
                frame.getScrollPane().setCursor(ToolPanel.TOOL_CURSORS[j]);
            }
        });
        toolMenu.add(toolMenuItems[i]);
    }

    // We also add a menu item for deleting Bezier Curves via the Backspace key.
    setDelete(new JMenuItem("Delete Curves"));
    getDelete().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            frame.deleteCurve();
        }
    });
    getDelete().setEnabled(false);
    getDelete().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
    toolMenu.addSeparator();
    toolMenu.add(getDelete());

    setEnter(new JMenuItem("Enter Curve"));
    getEnter().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.enterCurve();
        }
    });
    getEnter().setEnabled(false);
    getEnter().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    toolMenu.add(getEnter());

    fit = new JMenuItem("Fit Curve");
    fit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.fitCurves();
        }
    });
    fit.setEnabled(false);
    fit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, 0));
    toolMenu.add(fit);
    toolMenu.addSeparator();

    // TODO remove this later
    // JMenuItem runTestScript = new JMenuItem ("Run Testing Script");
    // runTestScript.addActionListener (new ActionListener(){
    // public void actionPerformed (ActionEvent event){
    // try{frame.testingScript();}
    // catch(IOException e){System.out.println("Script Error");}
    // }});
    // runTestScript.setAccelerator (KeyStroke.getKeyStroke(KeyEvent.VK_S, 0));
    // toolMenu.add(runTestScript);
    JCheckBoxMenuItem toggleCtrlPtAdjustment = new JCheckBoxMenuItem("Enable Control Point Adjustment");
    toggleCtrlPtAdjustment.setState(frame.isEnableCtrlPtAdjustment());
    toggleCtrlPtAdjustment.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            frame.setEnableCtrlPtAdjustment(!frame.isEnableCtrlPtAdjustment());
            ;
        }
    });
    toggleCtrlPtAdjustment.setEnabled(true);
    toolMenu.add(toggleCtrlPtAdjustment);

    this.add(toolMenu);

    // Navigation Menu
    // TODO FIX action listeners to these.
    JMenu navigateMenu = new JMenu("Navigate");
    prevFrame = new JMenuItem("Previous Frame");
    nextFrame = new JMenuItem("Next Frame");
    prevKeyframe = new JMenuItem("Previous Keyframe");
    nextKeyframe = new JMenuItem("Next Keyframe");
    prevFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK));
    nextFrame.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.ALT_MASK));
    prevKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, DEFAULT_MASK));
    nextKeyframe.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, DEFAULT_MASK));
    prevFrame.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.getControlPanel().getCurrentLayerSlider()
                    .setValue(Math.max(frame.getControlPanel().getCurrentLayerSlider().getValue() - 1,
                            frame.getControlPanel().getCurrentLayerSlider().getMinimum()));
        }
    });
    nextFrame.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            frame.getControlPanel().getCurrentLayerSlider()
                    .setValue(Math.min(frame.getControlPanel().getCurrentLayerSlider().getValue() + 1,
                            frame.getControlPanel().getCurrentLayerSlider().getMaximum()));
        }
    });
    prevKeyframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
        }
    });
    nextKeyframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
        }
    });
    prevFrame.setEnabled(false);
    nextFrame.setEnabled(false);
    prevKeyframe.setEnabled(false);
    nextKeyframe.setEnabled(false);
    navigateMenu.add(prevFrame);
    navigateMenu.add(nextFrame);
    navigateMenu.add(prevKeyframe);
    navigateMenu.add(nextKeyframe);
    this.add(navigateMenu);

    // Image options.
    JMenu imageMenu = new JMenu("Image");

    // Brightness and Contrast tool. Taken from ImageJ.
    adjustBrightnessContrast = new JMenuItem("Adjust Brightness/Contrast");
    adjustBrightnessContrast.setEnabled(false);
    adjustBrightnessContrast.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ContrastAdjuster c = new ContrastAdjuster(frame);
            c.run("Brightness/Contrast...[C]");
        }
    });
    imageMenu.add(adjustBrightnessContrast);
    this.add(imageMenu);

    // Zoom-In and Zoom-Out Commands
    JMenu viewMenu = new JMenu("View");
    zoomIn = new JMenuItem("Zoom In");
    zoomOut = new JMenuItem("Zoom Out");
    zoomIn.addActionListener(new ZoomInListener(frame.getControlPanel()));
    zoomOut.addActionListener(new ZoomOutListener(frame.getControlPanel()));
    zoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MASK));
    zoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MASK));
    zoomIn.setEnabled(false);
    zoomOut.setEnabled(false);

    // Menu Item for showing bounding boxes
    setBoundingBoxMenu(new JCheckBoxMenuItem("Show Bounding Boxes"));
    getBoundingBoxMenu().setState(false);
    getBoundingBoxMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.drawImageOverlay();
        }
    });
    getBoundingBoxMenu().setEnabled(false);

    // Menu Item for choosing the x-axis values for the curvature and intensity
    // display
    // For instance, you can display x vs. curvature, or current arc length vs
    // curvature, or the point index vs curvature
    // The default is the point index.
    distributionDisplay = DEFAULT_DISTRIBUTION_DISPLAY;
    JMenu xAxisSubmenu = new JMenu("Curve Distribution X-Axis:");
    ButtonGroup xAxisGroup = new ButtonGroup();
    JMenuItem xValue = new JCheckBoxMenuItem("X-Coordinate");
    JMenuItem curveLength = new JCheckBoxMenuItem("Arc Length");
    JMenuItem pointIndex = new JCheckBoxMenuItem("Point Index");
    xAxisGroup.add(xValue);
    xAxisGroup.add(curveLength);
    xAxisGroup.add(pointIndex);
    xAxisSubmenu.add(xValue);
    xAxisSubmenu.add(curveLength);
    xAxisSubmenu.add(pointIndex);
    xValue.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            distributionDisplay = 0;
            frame.getInfoPanel().updateHistograms();
        }
    });
    curveLength.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            distributionDisplay = 1;
            frame.getInfoPanel().updateHistograms();
        }
    });
    pointIndex.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            distributionDisplay = 2;
            frame.getInfoPanel().updateHistograms();
        }
    });
    if (DEFAULT_DISTRIBUTION_DISPLAY == 0) {
        xValue.setSelected(true);
    } else if (DEFAULT_DISTRIBUTION_DISPLAY == 1) {
        curveLength.setSelected(true);
    } else {
        pointIndex.setSelected(true);
    }

    // Menu Item for scaling curve strokes when zooming in or out
    setScaleCurvesMenu(new JCheckBoxMenuItem("Scale Curve Strokes"));
    getScaleCurvesMenu().setState(true);
    getScaleCurvesMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.drawImageOverlay();
        }
    });
    getScaleCurvesMenu().setEnabled(false);

    // Menu Item for image antialiasing
    setAntialiasingMenu(new JCheckBoxMenuItem("Enable Antialiasing"));
    getAntialiasingMenu().setState(false);
    getAntialiasingMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.setScaledImage(frame.getControlPanel().getScaleSlider().getValue() / 100.0);
            frame.drawImageOverlay();
        }
    });
    getAntialiasingMenu().setEnabled(false);

    // Menu Item for displaying tangent and normal curves.
    setTangentMenu(new JCheckBoxMenuItem("Show Tangent and Normal Vectors"));
    getTangentMenu().setState(false);
    getTangentMenu().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent a) {
            frame.drawImageOverlay();
        }
    });
    getTangentMenu().setEnabled(false);

    viewMenu.add(zoomIn);
    viewMenu.add(zoomOut);
    viewMenu.addSeparator();
    viewMenu.add(xAxisSubmenu);
    viewMenu.addSeparator();
    viewMenu.add(getScaleCurvesMenu());
    viewMenu.add(getTangentMenu());
    viewMenu.add(getBoundingBoxMenu());
    viewMenu.add(getAntialiasingMenu());
    this.add(viewMenu);

    // Sets a "Help" menu list
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('H');

    // Adds an "About" option to the menu list
    JMenuItem aboutMenuItem = new JMenuItem("About...", 'A');
    aboutMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(frame, "Developed by the Brouhard lab, 2016-2017.",
                    KappaFrame.APPLICATION_NAME, JOptionPane.INFORMATION_MESSAGE);
        }
    });

    // Adds a link to the User Manual
    JMenuItem userManualLink = new JMenuItem("User Manual");
    userManualLink.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                if (Desktop.isDesktopSupported()) {
                    Desktop.getDesktop().browse(new URI(
                            "https://dl.dropboxusercontent.com/u/157117/KappaFrame%20User%20Manual.pdf"));
                }
            } catch (Exception e) {
                System.out.println("Incorrect URL Syntax");
            }
            ;
        }
    });

    // Adds all newly created menu items to the "Help" list
    helpMenu.add(userManualLink);
    helpMenu.add(aboutMenuItem);
    this.add(helpMenu);
}