Search in sources :

Example 46 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project knime-core by knime.

the class RankCorrelationComputeNodeView method getJMenu.

private JMenu getJMenu() {
    JMenu menu = new JMenu("View");
    JCheckBoxMenuItem useColorBox = new JCheckBoxMenuItem("Use Colors");
    useColorBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (((JCheckBoxMenuItem) e.getSource()).isSelected()) {
                changeRenderer(ColorRender.DESCRIPTION);
            } else {
                changeRenderer(DoubleValueRenderer.STANDARD_RENDERER.getDescription());
            }
        }
    });
    useColorBox.addPropertyChangeListener("ancestor", new PropertyChangeListener() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            ((JCheckBoxMenuItem) evt.getSource()).setSelected(m_currentRendererID.equals(ColorRender.DESCRIPTION));
        }
    });
    JMenuItem colWidthItem = new JMenuItem("Cell Size...");
    colWidthItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            int colWidth = m_tableView.getColumnWidth();
            JSpinner s = new JSpinner(new SpinnerNumberModel(colWidth, 1, Integer.MAX_VALUE, 1));
            int r = JOptionPane.showConfirmDialog(m_tableView, s, "Cell Size", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (r == JOptionPane.OK_OPTION) {
                m_tableView.setColumnWidth((Integer) s.getValue());
                m_tableView.setRowHeight((Integer) s.getValue());
            }
        }
    });
    menu.add(useColorBox);
    menu.add(colWidthItem);
    return menu;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 47 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project knime-core by knime.

the class PMCCNodeView method getJMenu.

private JMenu getJMenu() {
    JMenu menu = new JMenu("View");
    JCheckBoxMenuItem useColorBox = new JCheckBoxMenuItem("Use Colors");
    useColorBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            if (((JCheckBoxMenuItem) e.getSource()).isSelected()) {
                changeRenderer(ColorRender.DESCRIPTION);
            } else {
                changeRenderer(DoubleValueRenderer.STANDARD_RENDERER.getDescription());
            }
        }
    });
    useColorBox.addPropertyChangeListener("ancestor", new PropertyChangeListener() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            ((JCheckBoxMenuItem) evt.getSource()).setSelected(m_currentRendererID.equals(ColorRender.DESCRIPTION));
        }
    });
    JMenuItem colWidthItem = new JMenuItem("Cell Size...");
    colWidthItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            int colWidth = m_tableView.getColumnWidth();
            JSpinner s = new JSpinner(new SpinnerNumberModel(colWidth, 1, Integer.MAX_VALUE, 1));
            int r = JOptionPane.showConfirmDialog(m_tableView, s, "Cell Size", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (r == JOptionPane.OK_OPTION) {
                m_tableView.setColumnWidth((Integer) s.getValue());
                m_tableView.setRowHeight((Integer) s.getValue());
            }
        }
    });
    menu.add(useColorBox);
    menu.add(colWidthItem);
    return menu;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 48 with JCheckBoxMenuItem

use of javax.swing.JCheckBoxMenuItem in project knime-core by knime.

the class Rule2DPlotter method getHiLiteMenu.

/**
 * {@inheritDoc}
 */
@Override
public JMenu getHiLiteMenu() {
    JMenu menu = super.getHiLiteMenu();
    if (m_hiliteRules == null && m_unhiliteRules == null) {
        menu.addSeparator();
        JMenuItem item;
        /*-------"hilite selected rules"----*/
        m_hiliteRules = new JMenuItem(HILITE_RULES);
        m_hiliteRules.setEnabled(false);
        m_hiliteRules.addActionListener(this);
        menu.add(m_hiliteRules);
        /*----------"unhilite selected rules"-----*/
        m_unhiliteRules = new JMenuItem(UNHILITE_RULES);
        // item.setEnabled(rulesSelected);
        m_unhiliteRules.addActionListener(this);
        m_unhiliteRules.setEnabled(false);
        menu.add(m_unhiliteRules);
        /* --- "[ ] hide unhilited rules" --- */
        item = new JCheckBoxMenuItem(HIDE_UNHILITED_RULES, getDrawingPane().isHideUnhilitedRules());
        item.addActionListener(this);
        menu.add(item);
    }
    return menu;
}
Also used : JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Aggregations

JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)48 ActionEvent (java.awt.event.ActionEvent)21 JMenuItem (javax.swing.JMenuItem)21 ActionListener (java.awt.event.ActionListener)18 JMenu (javax.swing.JMenu)17 JPopupMenu (javax.swing.JPopupMenu)12 AbstractAction (javax.swing.AbstractAction)8 JMenuBar (javax.swing.JMenuBar)6 JSeparator (javax.swing.JSeparator)5 JSpinner (javax.swing.JSpinner)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 JTableHeader (javax.swing.table.JTableHeader)4 TableColumn (javax.swing.table.TableColumn)4 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)3 Component (java.awt.Component)2 ItemEvent (java.awt.event.ItemEvent)2 HashMap (java.util.HashMap)2 Action (javax.swing.Action)2 ButtonGroup (javax.swing.ButtonGroup)2