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(String text, boolean b) 

Source Link

Document

Creates a check box menu item with the specified text and selection state.

Usage

From source file:net.sf.firemox.stack.EventManager.java

/**
 * Create an instance of MEventManager by reading a file
 * /*w  w  w  . j  a  v a2  s .c om*/
 * @since 0.31 graphical representation of phases for both players
 */
public static void init() {
    MPhase.optionsMenu = new JPopupMenu();
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(LanguageManager.getString("breakpoint"),
            new javax.swing.ImageIcon(IdConst.IMAGES_DIR + "breakpoint.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("breakpoint.tooltip"));
    item.setMnemonic('b');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setBreakpoint(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });
    MPhase.optionsMenu.add(item);
    item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhase"), UIHelper.getIcon("skipall1.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("skipPhase.tooltip"));
    item.setMnemonic('l');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setSkipAll(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });
    MPhase.optionsMenu.add(item);
    item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseOnce"), UIHelper.getIcon("skipall2.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseOnce.tooltip") + "<br><br>"
            + MagicUIComponents.HTML_ICON_TIP + LanguageManager.getString("skipPhaseOnceTTtip"));
    item.setMnemonic('o');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setSkipAllTmp(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });

    MPhase.optionsMenu.add(item);
    item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseMedium"),
            UIHelper.getIcon("skipallm2.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseMedium.tooltip") + "<br>"
            + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn"));
    item.setMnemonic('m');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setSkipMedium(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });
    MPhase.optionsMenu.add(item);
    item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseMediumOnce"),
            UIHelper.getIcon("skipallm.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseMediumOnce.tooltip") + "<br>"
            + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn"));
    item.setMnemonic('p');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setSkipMediumTmp(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });

    MPhase.optionsMenu.add(item);
    item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseAll"), UIHelper.getIcon("skipall3.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseAll.tooltip") + "<br>"
            + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn"));
    item.setMnemonic('u');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setSkipAllVery(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });
    MPhase.optionsMenu.add(item);
    item = new JCheckBoxMenuItem(LanguageManager.getString("skipPhaseAllOnce"),
            UIHelper.getIcon("skipall4.gif"));
    item.setFont(MToolKit.defaultFont);
    item.setToolTipText("<html>" + LanguageManager.getString("skipPhaseAllOnce.tooltip") + "<br>"
            + MagicUIComponents.HTML_ICON_WARNING + LanguageManager.getString("skipPhaseAllTTwarn"));
    item.setMnemonic('t');
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MPhase.triggerPhase.setSkipAllVeryTmp(((JCheckBoxMenuItem) evt.getSource()).isSelected());
            MPhase.triggerPhase.repaint();
        }
    });
    MPhase.optionsMenu.add(item);
}

From source file:components.TabComponentsDemo.java

private void initMenu() {
    JMenuBar menuBar = new JMenuBar();
    //create Options menu
    tabComponentsItem = new JCheckBoxMenuItem("Use TabComponents", true);
    tabComponentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK));
    tabComponentsItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < pane.getTabCount(); i++) {
                if (tabComponentsItem.isSelected()) {
                    initTabComponent(i);
                } else {
                    pane.setTabComponentAt(i, null);
                }/* ww w. ja  v  a2  s .c o m*/
            }
        }
    });
    scrollLayoutItem = new JCheckBoxMenuItem("Set ScrollLayout");
    scrollLayoutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK));
    scrollLayoutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (pane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) {
                pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
            } else {
                pane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
            }
        }
    });
    JMenuItem resetItem = new JMenuItem("Reset JTabbedPane");
    resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK));
    resetItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            runTest();
        }
    });

    JMenu optionsMenu = new JMenu("Options");
    optionsMenu.add(tabComponentsItem);
    optionsMenu.add(scrollLayoutItem);
    optionsMenu.add(resetItem);
    menuBar.add(optionsMenu);
    setJMenuBar(menuBar);
}

From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java

/**
 * Create the Statistics Menu, showing all available statistics for the
 * chosen ChartableKstat.//from ww  w.j  av  a 2 s.c  o  m
 *
 * @param cks the Kstat to show the statistics of in the menu
 * @param statistic the initial statistic, which will be checked
 *
 * @return the Statistics Menu
 */
protected JMenu statisticsMenu(ChartableKstat cks, String statistic) {
    JMenu jmstat = new JMenu(KstatResources.getString("CHART.SHOW"));
    jmstat.setMnemonic(KeyEvent.VK_S);
    for (String stat : cks.getStatistics()) {
        JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(stat, stat.equals(statistic));
        jmi.addActionListener(this);
        jmstat.add(jmi);
    }
    return jmstat;
}

From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java

public void setAvailableMetrics(Vector<String> names) {
    Vector<String> temp = new Vector<String>();
    temp.addAll(names);// w  ww . j av  a2s .c o m
    temp.add("Online Peers");
    temp.add("Available Attributes");
    temp.add("Memory Usage");
    Collections.sort(temp);

    JMenu met = mb.getMenu(1);
    met.setEnabled(true);
    JMenu avgMet = new JMenu("Average Metrics");
    JMenu genMet = new JMenu("General Metrics");
    JMenu recMet = new JMenu("Metrics for Receiving");
    JMenu sentMet = new JMenu("Metrics for Sending");
    JCheckBoxMenuItem item = null;
    for (String name : temp) {
        if (name.startsWith("Aver")) {
            item = new JCheckBoxMenuItem(name, false);
            item.addActionListener(this);
            avgMet.add(item);
        } else if (name.startsWith("Rec")) {
            item = new JCheckBoxMenuItem(name, false);
            item.addActionListener(this);
            recMet.add(item);
        } else if (name.startsWith("Sent")) {
            item = new JCheckBoxMenuItem(name, false);
            item.addActionListener(this);
            sentMet.add(item);
        } else {
            item = new JCheckBoxMenuItem(name, false);
            item.addActionListener(this);
            genMet.add(item);
        }
    }
    avgMet.add(new JSeparator(SwingConstants.HORIZONTAL));
    avgMet.add(createMenuItem("Display all Average Metrics"));
    avgMet.add(createMenuItem("Remove all Average Metrics"));

    genMet.add(new JSeparator(SwingConstants.HORIZONTAL));
    genMet.add(createMenuItem("Display all General Metrics"));
    genMet.add(createMenuItem("Remove all General Metrics"));

    recMet.add(new JSeparator(SwingConstants.HORIZONTAL));
    recMet.add(createMenuItem("Display all Metrics for Receiving"));
    recMet.add(createMenuItem("Remove all Metrics for Receiving"));

    sentMet.add(new JSeparator(SwingConstants.HORIZONTAL));
    sentMet.add(createMenuItem("Display all Metrics for Sending"));
    sentMet.add(createMenuItem("Remove all Metrics for Sending"));

    met.add(avgMet);
    met.add(genMet);
    met.add(recMet);
    met.add(sentMet);

    met.add(new JSeparator(SwingConstants.HORIZONTAL));
    met.add(createMenuItem("Display all Metrics"));
    met.add(createMenuItem("Remove all Metrics"));

    mb.add(met);
    repaint();
    log.warn("Created Menu 'Available Metrics'");
}

From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java

/**
 * Create the Statistics Menu, showing all available statistics for the
 * chosen ChartableKstat.//from  w w  w  .  j  av a 2s .com
 *
 * @param cks the ChartableKstat to show the statistics of in the menu
 * @param statistics the initial statistics, which will be checked
 *
 * @return the Statistics Menu
 */
protected JMenu statisticsMenu(ChartableKstat cks, List<String> statistics) {
    JMenu jmstat = new JMenu(KstatResources.getString("CHART.SHOW"));
    jmstat.setMnemonic(KeyEvent.VK_S);
    for (String stat : cks.getStatistics()) {
        JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(stat, statistics.contains(stat));
        jmi.addActionListener(this);
        jmstat.add(jmi);
    }
    return jmstat;
}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * Build menu./*from   w  w w.j  av a2 s.  c o m*/
 */
public void makeMenu() {
    JMenuItem menuItem;

    JMenu menu;
    JMenu submenu;

    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    menu = new JMenu(Menu.MENU_FILE);
    menu.setMnemonic(KeyEvent.VK_F);
    menuItem = new JMenuItem(Menu.NEW_SCHEME, KeyEvent.VK_N);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.LOAD_SCHEME, KeyEvent.VK_O);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.RELOAD_SCHEME, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.SAVE_SCHEME, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.SAVE_SCHEME_AS);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.DELETE_SCHEME, KeyEvent.VK_D);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    submenu = new JMenu(Menu.EXPORT_MENU);
    menu.add(submenu);
    //submenu.setMnemonic( KeyEvent.VK_E );

    SchemeExporter.makeSchemeExportMenu(submenu, getActionListener());

    // Export window graphics
    submenu.add(GraphicsExporter.getExportMenu());

    menu.addSeparator();
    menuItem = new JMenuItem(Menu.PRINT, KeyEvent.VK_P);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menu.addSeparator();
    menuItem = new JMenuItem(Menu.EXIT, KeyEvent.VK_X);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuBar.add(menu);
    menu = new JMenu(Menu.MENU_EDIT);
    menu.setMnemonic(KeyEvent.VK_E);

    menu.add(undoAction);
    menu.add(redoAction);
    menu.add(cloneAction);

    menuItem = new JMenuItem(Menu.SCHEME_FIND, KeyEvent.VK_F);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.SELECT_ALL, KeyEvent.VK_A);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.CLEAR_ALL, KeyEvent.VK_C);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    final JCheckBoxMenuItem painterEnabled = new JCheckBoxMenuItem(Menu.CLASSPAINTER, true);
    painterEnabled.addActionListener(getActionListener());
    menu.add(painterEnabled);

    menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Canvas canvas = Editor.getInstance().getCurrentCanvas();
            if (canvas == null || !canvas.getPackage().hasPainters()) {
                painterEnabled.setVisible(false);
            } else {
                painterEnabled.setVisible(true);
                painterEnabled.setSelected(canvas.isEnableClassPainter());
            }
        }

    });

    menuBar.add(menu);

    menu = new JMenu(Menu.MENU_VIEW);
    menu.setMnemonic(KeyEvent.VK_V);
    gridCheckBox = new JCheckBoxMenuItem(Menu.GRID, RuntimeProperties.isShowGrid());
    gridCheckBox.setMnemonic('G');
    gridCheckBox.addActionListener(getActionListener());
    menu.add(gridCheckBox);

    ctrlCheckBox = new JCheckBoxMenuItem(Menu.CONTROL_PANEL, RuntimeProperties.isShowControls());
    ctrlCheckBox.setMnemonic('C');
    ctrlCheckBox.addActionListener(getActionListener());
    menu.add(ctrlCheckBox);

    showPortCheckBox = new JCheckBoxMenuItem(Menu.SHOW_PORTS, true);
    showPortCheckBox.addActionListener(getActionListener());
    menu.add(showPortCheckBox);

    showObjectNamesCheckBox = new JCheckBoxMenuItem(Menu.SHOW_NAMES, false);
    showObjectNamesCheckBox.addActionListener(getActionListener());
    menu.add(showObjectNamesCheckBox);

    //sync View with current canvas
    menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            Canvas canvas;

            if ((canvas = getCurrentCanvas()) == null)
                return;

            gridCheckBox.setSelected(canvas.isGridVisible());
            ctrlCheckBox.setSelected(canvas.isCtrlPanelVisible());
            showPortCheckBox.setSelected(canvas.isDrawPorts());
            showObjectNamesCheckBox.setSelected(canvas.isShowObjectNames());
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });

    menuBar.add(menu);

    menu = new JMenu(Menu.MENU_PACKAGE);
    menu.setMnemonic(KeyEvent.VK_P);
    menuItem = new JMenuItem(Menu.LOAD, KeyEvent.VK_L);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.RELOAD, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.INFO, KeyEvent.VK_I);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    if (Desktop.isDesktopSupported()) {
        menuItem = new JMenuItem(Menu.BROWSE_PACKAGE, KeyEvent.VK_B);
        menuItem.addActionListener(getActionListener());
        menu.add(menuItem);
    }
    menuItem = new JMenuItem(Menu.CLOSE, KeyEvent.VK_C);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuItem = new JMenuItem(Menu.CLOSE_ALL);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menuBar.add(menu);
    menu.add(new JSeparator());
    final JMenu submenuRecent = new JMenu(Menu.RECENT);
    submenuRecent.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        final JMenuItem empty = new JMenuItem("Empty");

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            makeRecentSubMenu(submenuRecent);

            if (submenuRecent.getMenuComponentCount() == 0) {

                submenuRecent.add(empty);
                empty.setEnabled(false);

            } else {
                if (!((submenuRecent.getMenuComponentCount() == 1)
                        && (submenuRecent.getPopupMenu().getComponentIndex(empty) >= -1))) {
                    submenuRecent.remove(empty);
                }
            }

        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });
    menu.add(submenuRecent);
    final JMenu menuScheme = new JMenu(Menu.MENU_SCHEME);
    menuScheme.setMnemonic(KeyEvent.VK_S);
    makeSchemeMenu(menuScheme);

    menuScheme.getPopupMenu().addPopupMenuListener(new PopupMenuListener() {

        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {

            makeSchemeMenu(menuScheme);

        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            // ignore
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            // ignore
        }

    });

    /*
     * menuItem = new JMenuItem("Planner");
     * menuItem.addActionListener(aListener); menuScheme.add(menuItem);
     * menuItem = new JMenuItem("Plan, compile, run");
     * menuItem.setActionCommand("Run");
     * menuItem.addActionListener(aListener); menuScheme.add(menuItem);
     */
    // menuScheme.setMnemonic(KeyEvent.VK_A);
    menuBar.add(menuScheme);
    menu = new JMenu(Menu.MENU_OPTIONS);
    menu.setMnemonic(KeyEvent.VK_O);

    menuItem = new JMenuItem(Menu.SETTINGS, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.CTRL_MASK));
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.FONTS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.SAVE_SETTINGS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    submenu = new JMenu(Menu.MENU_LAF);
    submenu.setMnemonic(KeyEvent.VK_L);
    Look.getInstance().createMenuItems(submenu);
    menu.add(submenu);
    menuBar.add(menu);

    makeToolsMenu(menuBar);

    menu = new JMenu(Menu.MENU_HELP);
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);
    menuItem = new JMenuItem(Menu.DOCS, KeyEvent.VK_D);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
}

From source file:org.rdv.viz.chart.ChartViz.java

/**
 * Create the chart and setup it's UI./*from  w w  w.  ja  va2s.  co m*/
 */
private void initChart() {
    XYToolTipGenerator toolTipGenerator;

    if (xyMode) {
        dataCollection = new XYTimeSeriesCollection();

        NumberAxis domainAxis = new NumberAxis();
        domainAxis.setAutoRangeIncludesZero(false);
        domainAxis.addChangeListener(new AxisChangeListener() {
            public void axisChanged(AxisChangeEvent ace) {
                boundsChanged();
            }
        });
        this.domainAxis = domainAxis;

        toolTipGenerator = new StandardXYToolTipGenerator("{0}: {1} , {2}", new DecimalFormat(),
                new DecimalFormat());
    } else {
        dataCollection = new TimeSeriesCollection();

        domainAxis = new FixedAutoAdjustRangeDateAxis();
        domainAxis.setLabel("Time");
        domainAxis.setAutoRange(false);

        toolTipGenerator = new StandardXYToolTipGenerator("{0}: {1} , {2}",
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"), new DecimalFormat());
    }

    rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.addChangeListener(new AxisChangeListener() {
        public void axisChanged(AxisChangeEvent ace) {
            boundsChanged();
        }
    });

    FastXYItemRenderer renderer = new FastXYItemRenderer(StandardXYItemRenderer.LINES, toolTipGenerator);
    renderer.setBaseCreateEntities(false);
    renderer.setBaseStroke(new BasicStroke(0.5f));
    if (xyMode) {
        renderer.setCursorVisible(true);
    }

    xyPlot = new XYPlot(dataCollection, domainAxis, rangeAxis, renderer);

    chart = new JFreeChart(xyPlot);
    chart.setAntiAlias(false);

    seriesLegend = chart.getLegend();
    chart.removeLegend();

    chartPanel = new ChartPanel(chart, true);
    chartPanel.setInitialDelay(0);

    // get the chart panel standard popup menu
    JPopupMenu popupMenu = chartPanel.getPopupMenu();

    // create a popup menu item to copy an image to the clipboard
    final JMenuItem copyChartMenuItem = new JMenuItem("Copy");
    copyChartMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            copyChart();
        }
    });
    popupMenu.insert(copyChartMenuItem, 2);

    popupMenu.insert(new JPopupMenu.Separator(), 3);

    popupMenu.add(new JPopupMenu.Separator());

    showLegendMenuItem = new JCheckBoxMenuItem("Show Legend", true);
    showLegendMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setShowLegend(showLegendMenuItem.isSelected());
        }
    });
    popupMenu.add(showLegendMenuItem);

    if (xyMode) {
        popupMenu.add(new JPopupMenu.Separator());

        JMenuItem addLocalSeriesMenuItem = new JMenuItem("Add local series...");
        addLocalSeriesMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                addLocalSeries();
            }
        });

        popupMenu.add(addLocalSeriesMenuItem);
    }

    chartPanelPanel = new JPanel();
    chartPanelPanel.setLayout(new BorderLayout());
    chartPanelPanel.add(chartPanel, BorderLayout.CENTER);
}

From source file:ucar.unidata.idv.control.chart.ChartWrapper.java

/**
 * Add the default menu items//www .  j av a2  s .  c o m
 *
 *
 * @param items List of menu items
 *
 * @return The items list
 */
protected List getPopupMenuItems(List items) {

    if (canDoParameters()) {
        items.add(GuiUtils.makeMenuItem("Add Field...", this, "addField"));
    }

    if (canDoJython() && (jython != null) && (jython.trim().length() > 0)) {
        items.add(GuiUtils.makeMenuItem("Apply Jython", this, "applyJython", jython));

    }

    items.add(GuiUtils.makeMenuItem("Remove Chart", this, "removeDisplayComponent"));

    items.add(GuiUtils.MENU_SEPARATOR);
    items.add(GuiUtils.makeMenuItem("Save Image...", this, "doSaveImage"));
    items.add(GuiUtils.makeMenuItem("Save Movie...", this, "doSaveMovie"));

    if (canDoDriveTime()) {
        items.add(GuiUtils.MENU_SEPARATOR);

        final JCheckBoxMenuItem mi1 = new JCheckBoxMenuItem("Show Animation Times", showTime);
        items.add(mi1);
        mi1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                showTime = mi1.isSelected();
            }
        });

        final JCheckBoxMenuItem mi2 = new JCheckBoxMenuItem("Drive Animation Times", driveTime);
        items.add(mi2);
        mi2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                driveTime = mi2.isSelected();
            }
        });

    }

    if (canDoTimeFilters() && (getDisplayGroup() != null)) {
        List comps = getDisplayGroup().getAncestorGroup().findDisplayComponents(ChartWrapper.class);
        JMenu filterMenu = null;
        boolean didSep = false;
        if (timeFilterSource != null) {
            filterMenu = new JMenu("Time Subset");
            didSep = true;
            items.add(GuiUtils.MENU_SEPARATOR);
            items.add(filterMenu);
            filterMenu.add(GuiUtils.makeMenuItem("Remove", ChartWrapper.this, "removeTimeFilterSource"));
        }

        for (int i = 0; i < comps.size(); i++) {
            ChartWrapper chartWrapper = (ChartWrapper) comps.get(i);
            if (chartWrapper.getTimeRanges() == null) {
                continue;
            }
            if (filterMenu == null) {
                filterMenu = new JMenu("Time Subset");
                if (!didSep) {
                    items.add(GuiUtils.MENU_SEPARATOR);
                }
                didSep = true;
                items.add(filterMenu);
            }
            filterMenu.add(GuiUtils.makeMenuItem("From: " + chartWrapper.getName(), ChartWrapper.this,
                    "setTimeFilterSource", chartWrapper));
        }

    }

    if (canDoTimeSelect() && (getDisplayGroup() != null)) {
        List comps = getDisplayGroup().getAncestorGroup().findDisplayComponents(ChartWrapper.class);
        JMenu filterMenu = null;
        boolean didSep = false;
        if (timeSelectSource != null) {
            filterMenu = new JMenu("Time Select");
            didSep = true;
            items.add(GuiUtils.MENU_SEPARATOR);
            items.add(filterMenu);
            filterMenu.add(GuiUtils.makeMenuItem("Remove", ChartWrapper.this, "removeTimeSelectSource"));
        }

        for (int i = 0; i < comps.size(); i++) {
            ChartWrapper chartWrapper = (ChartWrapper) comps.get(i);
            if ((chartWrapper == this) || !chartWrapper.canBeASourceForTimeSelectionEvents()) {
                continue;
            }

            if (filterMenu == null) {
                filterMenu = new JMenu("Time Select");
                if (!didSep) {
                    items.add(GuiUtils.MENU_SEPARATOR);
                }
                didSep = true;
                items.add(filterMenu);
            }
            filterMenu.add(GuiUtils.makeMenuItem("From: " + chartWrapper.getName(), ChartWrapper.this,
                    "setTimeSelectSource", chartWrapper));
        }

    }

    items.add(GuiUtils.MENU_SEPARATOR);
    items.add(GuiUtils.makeMenuItem("Properties...", this, "showProperties"));

    return items;

}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * @param menu/*from  www  . j a  va  2s . co m*/
 */
private void makeSchemeMenu(JMenu menu) {
    menu.removeAll();

    // Specification...
    JMenuItem menuItem = new JMenuItem(Menu.SPECIFICATION, KeyEvent.VK_S);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    //Extend
    menuItem = new JMenuItem(Menu.EXTEND_SPEC, KeyEvent.VK_E);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
    menu.add(new JSeparator());
    // Run
    menuItem = new JMenuItem(Menu.RUN, KeyEvent.VK_R);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    //Propagate
    menuItem = new JCheckBoxMenuItem(Menu.PROPAGATE_VALUES, RuntimeProperties.isPropagateValues());
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    //Compute goal
    menuItem = new JCheckBoxMenuItem(Menu.COMPUTE_GOAL, RuntimeProperties.isComputeGoal());
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menu.add(new JSeparator());

    // Values
    menuItem = new JMenuItem(Menu.SCHEME_VALUES, KeyEvent.VK_V);
    menuItem.addActionListener(getActionListener());
    boolean enabled = getCurrentCanvas() != null && getCurrentCanvas().getLastProgramRunnerID() != 0;
    menuItem.setEnabled(enabled);
    if (!enabled)
        menuItem.setToolTipText("Run the scheme first");
    menu.add(menuItem);

    menu.add(new JSeparator());

    // Options
    menuItem = new JMenuItem(Menu.SCHEMEOPTIONS, KeyEvent.VK_O);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
}

From source file:ee.ioc.cs.vsle.editor.Editor.java

/**
 * /*  w  ww .j  a v  a  2 s .  c  o m*/
 */
private void makeToolsMenu(JMenuBar _menuBar) {

    JMenu menu = new JMenu(Menu.MENU_TOOLS);
    menu.setMnemonic(KeyEvent.VK_T);
    _menuBar.add(menu);

    JMenuItem menuItem = new JMenuItem(Menu.EXPERT_TABLE);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    if (RuntimeProperties.isFromWebstart()) {
        menuItem = new JMenuItem(Menu.ICON_EDITOR);
        menuItem.addActionListener(getActionListener());
        menu.add(menuItem);
    }

    menuItem = new JCheckBoxMenuItem(Menu.SHOW_ALGORITHM, RuntimeProperties.isShowAlgorithm());
    menuItem.setToolTipText("If checked, after planning a window with the synthesized algorithm will be shown");
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.VIEW_THREADS);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);

    menuItem = new JMenuItem(Menu.JAVA_CONSOLE);
    menuItem.addActionListener(getActionListener());
    menu.add(menuItem);
}