Search in sources :

Example 61 with JRadioButton

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

the class DialogComponentButtonGroup method createEnumButtonGroup.

/**
 * Creates a <code>ButtonGroup</code> with the labels elements as button
 * labels and the actionCommands as the button action commands.
 * @param labels the labels of the buttons
 * @param actionCommands the action commands of the buttons in the same
 * order like the labels
 * @param defaultAction the default action which should be selected
 * @param l the action listener to add to each button
 * @return the button group
 */
private static ButtonGroup createEnumButtonGroup(final String[] labels, final String[] actionCommands, final String defaultAction, final ActionListener l) {
    final ButtonGroup group = new ButtonGroup();
    boolean defaultFound = false;
    for (int i = 0, length = actionCommands.length; i < length; i++) {
        final JRadioButton button = new JRadioButton(labels[i]);
        button.setActionCommand(actionCommands[i]);
        if (defaultAction != null && actionCommands[i].equals(defaultAction)) {
            button.setSelected(true);
            defaultFound = true;
        }
        if (l != null) {
            button.addActionListener(l);
        }
        group.add(button);
    }
    if (!defaultFound && group.getButtonCount() > 0) {
        // select the first button if none is by default selected
        group.getElements().nextElement().setSelected(true);
    }
    return group;
}
Also used : JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup)

Example 62 with JRadioButton

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

the class RadionButtonPanel method setSelectedValue.

/**
 * @param selectedValue the selectedValue to set
 * @throws IllegalArgumentException if the given value is not contained in the values given in constructor
 */
public void setSelectedValue(final T selectedValue) {
    JRadioButton jRadioButton = m_buttonMap.get(selectedValue);
    CheckUtils.checkArgumentNotNull(jRadioButton, "No button for value '%s' defined.", selectedValue);
    jRadioButton.doClick();
}
Also used : JRadioButton(javax.swing.JRadioButton)

Example 63 with JRadioButton

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

the class SVMLearnerNodeDialog method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    for (DialogComponent comp : m_components) {
        comp.saveSettingsTo(settings);
    }
    for (JRadioButton button : m_kernels) {
        if (button.isSelected()) {
            String s = button.getText();
            settings.addString(SVMLearnerNodeModel.CFG_KERNELTYPE, s);
        }
    }
}
Also used : JRadioButton(javax.swing.JRadioButton) DialogComponent(org.knime.core.node.defaultnodesettings.DialogComponent) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 64 with JRadioButton

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

the class BasisFunctionPredictor2NodeDialog method addOtherControls.

/**
 * {@inheritDoc}
 */
@Override
protected void addOtherControls(final JPanel panel) {
    m_dontKnow = new JSpinner(new SpinnerNumberModel(0.0, 0.0, 1.0, 0.1));
    m_defaultButton = new JRadioButton("Default ", true);
    m_setButton = new JRadioButton("Use ");
    m_ignoreButton = new JRadioButton("Ignore ", true);
    // add don't know probability
    m_ignoreButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            selectionChanged();
        }
    });
    ButtonGroup bg = new ButtonGroup();
    bg.add(m_ignoreButton);
    bg.add(m_defaultButton);
    bg.add(m_setButton);
    m_dontKnow.setEditor(new JSpinner.NumberEditor(m_dontKnow, "#.##########"));
    m_dontKnow.setPreferredSize(new Dimension(75, 25));
    JPanel dontKnowPanel = new JPanel(new GridLayout(3, 1));
    dontKnowPanel.setBorder(BorderFactory.createTitledBorder(" Don't Know Class "));
    FlowLayout left = new FlowLayout(FlowLayout.LEFT);
    final JPanel ignorePanel = new JPanel(left), defaultPanel = new JPanel(left);
    ignorePanel.add(m_ignoreButton);
    defaultPanel.add(m_defaultButton);
    dontKnowPanel.add(ignorePanel);
    dontKnowPanel.add(defaultPanel);
    JPanel usePanel = new JPanel(left);
    dontKnowPanel.add(usePanel);
    usePanel.add(m_setButton);
    usePanel.add(m_dontKnow);
    panel.add(dontKnowPanel);
    m_defaultButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_dontKnow.setEnabled(false);
        }
    });
    m_setButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_dontKnow.setEnabled(true);
        }
    });
    getLayout().putConstraint(SpringLayout.EAST, dontKnowPanel, 0, SpringLayout.EAST, panel);
    getLayout().putConstraint(SpringLayout.WEST, dontKnowPanel, 0, SpringLayout.WEST, panel);
    super.setLastAdded(dontKnowPanel);
    getPanel().setPreferredSize(new Dimension(400, 240));
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner) Dimension(java.awt.Dimension)

Example 65 with JRadioButton

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

the class ColumnRowFilterPanel method instantiateComponents.

@SuppressWarnings("unchecked")
private void instantiateComponents(final RowFilterNodeDialogPane parentPane, final DataTableSpec tSpec) throws NotConfigurableException {
    /* instantiate the col idx selector, depending on the table spec */
    assert ((tSpec != null) && (tSpec.getNumColumns() > 0));
    Vector<String> colNames = new Vector<String>();
    for (int c = 0; c < tSpec.getNumColumns(); c++) {
        colNames.add(tSpec.getColumnSpec(c).getName());
    }
    m_colCombo = new ColumnSelectionComboxBox((Border) null, DataValue.class);
    m_colCombo.update(tSpec, null);
    m_colCombo.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            selectedColChanged();
        }
    });
    m_deepFiltering = new JCheckBox("filter based on collection elements");
    /* the selectors for what kind of checking will be done */
    m_useRange = new JRadioButton("use range checking");
    m_useRegExpr = new JRadioButton("use pattern matching");
    m_useMissValue = new JRadioButton("only missing values match");
    m_useRange.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            radiosChanged();
        }
    });
    m_useRegExpr.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            radiosChanged();
        }
    });
    m_useMissValue.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            radiosChanged();
        }
    });
    m_radios = new ButtonGroup();
    m_radios.add(m_useRange);
    m_radios.add(m_useRegExpr);
    m_radios.add(m_useMissValue);
    /* the bound edit fields */
    m_lowerLabel = new JLabel("lower bound:");
    m_lowerLabel.setToolTipText("Smallest value of the range to be filtered.");
    m_lowerBound = new JTextField();
    m_upperLabel = new JLabel("upper bound:");
    m_upperLabel.setToolTipText("Largest value of the range to be filtered.");
    m_upperBound = new JTextField();
    m_lowerBound.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(final DocumentEvent e) {
            boundsChanged();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            boundsChanged();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            boundsChanged();
        }
    });
    m_upperBound.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(final DocumentEvent e) {
            boundsChanged();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            boundsChanged();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            boundsChanged();
        }
    });
    /* the regular expression stuff */
    m_regLabel = new JLabel("pattern:");
    // it's important that the column selection is created before!
    m_regExpr = new JComboBox(getPossibleValuesOfSelectedColumn());
    m_regExpr.setEditable(true);
    m_regExpr.setSelectedItem("");
    m_regExpr.setMinimumSize(new Dimension(50, m_regExpr.getPreferredSize().height));
    // m_regExpr.setPreferredSize(new Dimension(200, 50));
    m_regExpr.setMaximumSize(new Dimension(300, 50));
    JTextField ed = (JTextField) m_regExpr.getEditor().getEditorComponent();
    ed.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(final DocumentEvent e) {
            regExprChanged();
        }

        @Override
        public void removeUpdate(final DocumentEvent e) {
            regExprChanged();
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
            regExprChanged();
        }
    });
    m_regExpr.addItemListener(this);
    /* add flow variable button for the pattern/regexpr */
    FlowVariableModel fvm = parentPane.createFlowVariableModel(new String[] { RowFilterNodeModel.CFGFILTER, StringCompareRowFilter.CFGKEY_PATTERN }, FlowVariable.Type.STRING);
    fvm.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent evt) {
            FlowVariableModel fvm = (FlowVariableModel) (evt.getSource());
            m_regExpr.setEnabled(!fvm.isVariableReplacementEnabled());
            if (fvm.isVariableReplacementEnabled() && m_regExpr.getSelectedItem().equals("")) {
                // TODO: replace with more meaningful default - empty
                // pattern are rejected by dialog.
                m_regExpr.setSelectedItem(fvm.getInputVariableName());
            }
        }
    });
    m_regExprVarButton = new FlowVariableModelButton(fvm);
    m_caseSensitive = new JCheckBox("case sensitive match");
    m_isRegExpr = new JCheckBox("regular expression");
    m_hasWildCards = new JCheckBox("contains wild cards");
    m_hasWildCards.setToolTipText("insert '?' or '*' to match any one " + "character or any sequence (including none) of characters.");
    m_isRegExpr.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            wildRegExprChanged(e);
            // also trigger regular expression recompile
            regExprChanged();
        }
    });
    m_hasWildCards.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            wildRegExprChanged(e);
            // also trigger regular expression recompile
            regExprChanged();
        }
    });
    /* and a label to display errors/warnings */
    m_errText = new JTextArea();
    m_errText.setEditable(false);
    m_errText.setLineWrap(true);
    m_errText.setWrapStyleWord(true);
    m_errText.setBackground(getBackground());
    m_errText.setFont(new Font(m_errText.getFont().getName(), Font.BOLD, m_errText.getFont().getSize()));
    m_errText.setMinimumSize(new Dimension(350, 50));
    m_errText.setMaximumSize(new Dimension(350, 100));
    m_errText.setForeground(Color.RED);
    /* set the default values */
    m_useRegExpr.setSelected(true);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) JTextArea(javax.swing.JTextArea) DataValue(org.knime.core.data.DataValue) ColumnSelectionComboxBox(org.knime.core.node.util.ColumnSelectionComboxBox) JTextField(javax.swing.JTextField) Font(java.awt.Font) FlowVariableModel(org.knime.core.node.FlowVariableModel) ChangeListener(javax.swing.event.ChangeListener) Vector(java.util.Vector) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) DocumentEvent(javax.swing.event.DocumentEvent) JCheckBox(javax.swing.JCheckBox) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) FlowVariableModelButton(org.knime.core.node.FlowVariableModelButton) ItemListener(java.awt.event.ItemListener) Border(javax.swing.border.Border)

Aggregations

JRadioButton (javax.swing.JRadioButton)323 ButtonGroup (javax.swing.ButtonGroup)185 JPanel (javax.swing.JPanel)168 JLabel (javax.swing.JLabel)144 ActionEvent (java.awt.event.ActionEvent)104 ActionListener (java.awt.event.ActionListener)95 JTextField (javax.swing.JTextField)81 JButton (javax.swing.JButton)77 BoxLayout (javax.swing.BoxLayout)61 JCheckBox (javax.swing.JCheckBox)59 GridBagLayout (java.awt.GridBagLayout)57 BorderLayout (java.awt.BorderLayout)52 GridBagConstraints (java.awt.GridBagConstraints)52 Insets (java.awt.Insets)51 Dimension (java.awt.Dimension)45 FlowLayout (java.awt.FlowLayout)42 JScrollPane (javax.swing.JScrollPane)41 GridLayout (java.awt.GridLayout)32 JComboBox (javax.swing.JComboBox)32 ItemEvent (java.awt.event.ItemEvent)25