Example usage for javax.swing JCheckBoxMenuItem setToolTipText

List of usage examples for javax.swing JCheckBoxMenuItem setToolTipText

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

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

/**
 * Create an instance of MEventManager by reading a file
 * //www . j ava 2s.com
 * @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:SciTK.PlotXYZBlock.java

private void init(String x_label, String y_label, String window_title) {
    chart = ChartFactory.createScatterPlot("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true,
            false);//from w ww .j  av a2 s  .  com

    // turn off borders of the plot:
    XYPlot p = chart.getXYPlot();
    p.getDomainAxis().setLowerMargin(0.0);
    p.getDomainAxis().setUpperMargin(0.0);
    p.getRangeAxis().setLowerMargin(0.0);
    p.getRangeAxis().setUpperMargin(0.0);

    // --------------------------------------------
    //          set up a lookup table
    // --------------------------------------------
    // this is how we render the block plots:
    XYBlockRenderer renderer = new XYBlockRenderer();
    // need to find max and min z of the data set:
    double min = 0;
    double max = 0;
    for (int i = 0; i < data.getSeriesCount(); i++) // iterate over data sets
    {
        for (int j = 0; j < data.getItemCount(i); j++) // iterate over points in dataset
        {
            if (data.getZValue(i, j) < min)
                min = data.getZValue(i, j);
            else if (data.getZValue(i, j) > max)
                max = data.getZValue(i, j);
        }
    }
    // create paint scale using min and max values, default color black:
    LookupPaintScale paintScale = new LookupPaintScale(min, max, Color.black);
    // set up the LUT:
    double step_size = (max - min) / 255.; // step size for LUT
    for (int i = 0; i < 256; i++) {
        paintScale.add(min + i * step_size, new Color(i, i, i, 255));
    }
    renderer.setPaintScale(paintScale);
    // set this renderer to the plot:
    p.setRenderer(renderer);

    // --------------------------------------------
    //          set up a color bar
    // --------------------------------------------
    // create an array of display labels:
    num_labels = 10; // default to 10 labels on color bar
    double display_step_size = (max - min) / ((double) num_labels);
    String[] scale_bar_labels = new String[num_labels + 1];
    // to format numbers in scientific notation:
    DecimalFormat formater = new DecimalFormat("0.#E0");
    // create list of labesl:
    for (int i = 0; i <= num_labels; i++) {
        scale_bar_labels[i] = formater.format(min + i * display_step_size);
    }
    // create axis:
    SymbolAxis scaleAxis = new SymbolAxis(null, scale_bar_labels);
    scaleAxis.setRange(min, max);
    scaleAxis.setPlot(new PiePlot());
    scaleAxis.setGridBandsVisible(false);
    // set up the paint scale:
    psl = new PaintScaleLegend(paintScale, scaleAxis);
    psl.setBackgroundPaint(new Color(255, 255, 255, 0)); // clear background
    // set up frame with buffer region to allow text display
    psl.setFrame(new LineBorder((Paint) Color.BLACK, new BasicStroke((float) 1.0),
            new RectangleInsets(15, 10, 15, 10)));
    psl.setAxisOffset(5.0);
    // display on right side:
    psl.setPosition(RectangleEdge.RIGHT);
    // margin around color scale:
    psl.setMargin(new RectangleInsets(20, 15, 20, 15));
    // add to the chart so it will be displayed by default:
    chart.addSubtitle(psl);

    // --------------------------------------------
    //          WINDOW-RELATED UI
    // --------------------------------------------
    // set up the generic plot UI:
    super.window_title = window_title;
    super.initUI();

    // add another menu item
    JMenuBar mb = super.getJMenuBar(); // get the menu bar
    // find menu named "Plot"
    JMenu menu_plot = null;
    for (int i = 0; i < mb.getMenuCount(); i++) {
        if (mb.getMenu(i).getText() == "Plot")
            menu_plot = mb.getMenu(i);
    }
    // Add a new checkbox for the color scale bar
    JCheckBoxMenuItem menu_plot_scalebar = new JCheckBoxMenuItem("Color Scale");
    menu_plot_scalebar.setToolTipText("Show color scale bar?");
    menu_plot_scalebar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setScaleBar(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_scalebar.setState(true);
    if (menu_plot != null) // sanity check
        menu_plot.add(menu_plot_scalebar);

}

From source file:SciTK.Plot.java

/** 
 * Load the initial UI//from w  w w .  j a  v  a  2s . co m
 */
protected final void initUI() {
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    // create a ChartPanel, and make it default to 1/4 of screen size:
    chart_panel = new ChartPanel(chart);
    chart_panel.setPreferredSize(new Dimension(def_width, def_height));

    //add the chart to the window:
    getContentPane().add(chart_panel);

    // create a menu bar:
    menubar = new JMenuBar();
    // ---------------------------------------------------------
    //                 First dropdown menu: "File"
    // ---------------------------------------------------------
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    // Set up a save dialog option under the file menu:
    JMenuItem menu_file_save;
    ImageIcon menu_file_save_icon = null;
    try {
        menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png"));
        menu_file_save = new JMenuItem("Save", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save = new JMenuItem("Save");
    }
    menu_file_save.setMnemonic(KeyEvent.VK_S);
    menu_file_save.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_save.setToolTipText("Save an image");
    menu_file_save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveImage();
        }
    });
    file.add(menu_file_save);

    // Set up a save SVG dialog option under the file menu:
    JMenuItem menu_file_save_svg;
    try {
        menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_svg = new JMenuItem("Save VG");
    }
    menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)");
    menu_file_save_svg.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveVectorGraphics();
        }
    });
    file.add(menu_file_save_svg);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_save_data;
    try {
        menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon);
    } catch (Exception e) {
        menu_file_save_data = new JMenuItem("Save data");
    }
    menu_file_save_data.setToolTipText("Save raw data to file");
    menu_file_save_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            saveData();
        }
    });
    file.add(menu_file_save_data);

    // Set up a save data dialog option under the file menu:
    JMenuItem menu_file_print;
    try {
        ImageIcon menu_file_print_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/document-print-5.png"));
        menu_file_print = new JMenuItem("Print", menu_file_print_icon);
    } catch (Exception e) {
        menu_file_print = new JMenuItem("Print");
    }
    menu_file_print.setToolTipText("Print image of chart");
    menu_file_print.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            printPlot();
        }
    });
    file.add(menu_file_print);

    // menu item for exiting
    JMenuItem menu_file_exit;
    try {
        ImageIcon menu_file_exit_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/application-exit.png"));
        menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon);
    } catch (Exception e) {
        menu_file_exit = new JMenuItem("Exit");
    }
    menu_file_exit.setMnemonic(KeyEvent.VK_X);
    menu_file_exit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_file_exit.setToolTipText("Exit application");
    menu_file_exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dispose();
        }

    });
    file.add(menu_file_exit);

    // ---------------------------------------------------------
    //                 Second dropdown menu: "Edit"
    // ---------------------------------------------------------
    edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);

    // copy to clipboard
    JMenuItem menu_edit_copy_image;
    ImageIcon menu_edit_copy_icon = null;
    try {
        menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png"));
        menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_image = new JMenuItem("Copy");
    }
    menu_edit_copy_image.setMnemonic(KeyEvent.VK_C);
    menu_edit_copy_image.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menu_edit_copy_image.setToolTipText("Copy image to clipboard");
    menu_edit_copy_image.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyImage();
        }
    });
    edit.add(menu_edit_copy_image);

    // copy data to clipboard
    JMenuItem menu_edit_copy_data;
    try {
        menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon);
    } catch (Exception e) {
        menu_edit_copy_data = new JMenuItem("Copy data");
    }
    menu_edit_copy_data.setToolTipText("Copy data to clipboard");
    menu_edit_copy_data.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            copyData();
        }
    });
    edit.add(menu_edit_copy_data);

    // set background color
    JMenuItem menu_edit_BackgroundColor;
    ImageIcon menu_edit_Color_icon = null;
    try {
        menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png"));
        menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_BackgroundColor = new JMenuItem("Background Color");
    }
    menu_edit_BackgroundColor.setToolTipText("Select background color");
    menu_edit_BackgroundColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint());
            setBackgroundColor(bgColor);
        }
    });
    edit.add(menu_edit_BackgroundColor);

    // set plot color
    JMenuItem menu_edit_PlotColor;
    try {
        menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_PlotColor = new JMenuItem("Window Color");
    }
    menu_edit_PlotColor.setToolTipText("Select plot window color");
    menu_edit_PlotColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color plotColor = plotColorChooser("Choose plot color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setWindowBackground(plotColor);
        }
    });
    edit.add(menu_edit_PlotColor);

    // set gridline color
    JMenuItem menu_edit_GridlineColor;
    try {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon);
    } catch (Exception e) {
        menu_edit_GridlineColor = new JMenuItem("Gridline Color");
    }
    menu_edit_GridlineColor.setToolTipText("Select grid color");
    menu_edit_GridlineColor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Color gridColor = plotColorChooser("Choose grid color",
                    (Color) chart.getPlot().getBackgroundPaint());
            setGridlineColor(gridColor);
        }
    });
    edit.add(menu_edit_GridlineColor);

    // edit chart preferences
    JMenuItem menu_edit_preferences;
    try {
        ImageIcon menu_edit_preferences_icon = new ImageIcon(
                getClass().getResource("/SciTK/resources/preferences-desktop-3.png"));
        menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon);
    } catch (Exception e) {
        menu_edit_preferences = new JMenuItem("Preferences");
    }
    menu_edit_preferences.setToolTipText("Edit chart preferences");
    menu_edit_preferences.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            chart_panel.doEditChartProperties();
        }
    });
    edit.add(menu_edit_preferences);

    // ---------------------------------------------------------
    //                 Third dropdown menu: "Plot"
    // ---------------------------------------------------------
    plot = new JMenu("Plot");
    plot.setMnemonic(KeyEvent.VK_P);

    // Options to set log axes
    JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis");
    menu_plot_ylog.setToolTipText("Set y axis to logarithmic");
    menu_plot_ylog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setRangeAxisLog(selected);
        }
    });
    plot.add(menu_plot_ylog);

    JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis");
    menu_plot_xlog.setToolTipText("Set x axis to logarithmic");
    menu_plot_xlog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setDomainAxisLog(selected);
        }
    });
    plot.add(menu_plot_xlog);

    // grid line display
    JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines");
    menu_plot_grid.setToolTipText("Show plot grid lines?");
    menu_plot_grid.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setGridlineVisible(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible());
    plot.add(menu_plot_grid);

    // control for displaying plot legend
    JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend");
    menu_plot_legend.setToolTipText("Show plot legend?");
    menu_plot_legend.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            setLegend(selected);
        }
    });
    // set appropirate checkbox state:
    menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle));
    plot.add(menu_plot_legend);

    // ---------------------------------------------------------
    //                 General UI
    // ---------------------------------------------------------
    // Add menus to the menu bar:
    menubar.add(file);
    menubar.add(edit);
    menubar.add(plot);
    // Set menubar as this JFrame's menu
    setJMenuBar(menubar);

    // set default plot colors:
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255));
    setBackgroundAlpha(0.0f);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setTitle(window_title);
    setLocationRelativeTo(null);
    setVisible(true);
}

From source file:pl.otros.logview.gui.LogViewPanel.java

private void addMessageFormatterOrColorizerToMenu(final JPopupMenu menu, final PluginableElement pluginable,
        final PluginableElementsContainer selectedPluginableContainer) {
    {//from   w ww .j  av  a 2s.c o m
        final JCheckBoxMenuItem boxMenuItem = new JCheckBoxMenuItem(pluginable.getName(),
                selectedPluginableContainer.contains(pluginable));
        boxMenuItem.setToolTipText(pluginable.getDescription());
        menu.add(boxMenuItem);
        boxMenuItem.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                if (boxMenuItem.isSelected() && !selectedPluginableContainer.contains(pluginable)) {
                    selectedPluginableContainer.addElement(pluginable);
                } else if (!boxMenuItem.isSelected() && selectedPluginableContainer.contains(pluginable)) {
                    selectedPluginableContainer.removeElement(pluginable);
                }
            }
        });
    }
}