Search in sources :

Example 11 with ButtonModel

use of javax.swing.ButtonModel in project scylla by bptlab.

the class ScalingCheckBoxIcon method paintIcon.

/**
 * Overriden paint method
 */
@Override
public void paintIcon(Component checkBox, Graphics g, int x, int y) {
    int xoff = (size) / 8;
    int yoff = (checkBox.getHeight() - size) / 2;
    int border = size / 8;
    ButtonModel checkBoxModel = ((AbstractButton) checkBox).getModel();
    g.setColor(ScyllaGUI.ColorField2);
    g.fillRect(xoff, yoff, size, size);
    g.setColor(ScyllaGUI.ColorBackground);
    if (!checkBoxModel.isRollover())
        g.drawRect(xoff, yoff, size, size);
    if (checkBoxModel.isPressed()) {
        g.setColor(ScyllaGUI.ColorField1);
        g.fillRect(border + xoff, border + yoff, size - 2 * border + 1, size - 2 * border + 1);
    } else if (checkBoxModel.isSelected()) {
        g.setColor(ScyllaGUI.ColorBackground);
        g.fillRect(border + xoff, border + yoff, size - 2 * border + 1, size - 2 * border + 1);
    }
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Example 12 with ButtonModel

use of javax.swing.ButtonModel in project vcell by virtualcell.

the class ResourceImportPanel method getSelectedOption.

public T getSelectedOption() {
    T selectedOption = null;
    ButtonModel selectedButtonModel = buttonGroup.getSelection();
    if (selectedButtonModel != null) {
        selectedOption = button2optionMap.get(selectedButtonModel);
    }
    return selectedOption;
}
Also used : ButtonModel(javax.swing.ButtonModel)

Example 13 with ButtonModel

use of javax.swing.ButtonModel in project vcell by virtualcell.

the class PropertyChangeButtonGroup method setSelected.

/**
 * Sets the selected value for the button.
 */
@Override
public void setSelected(ButtonModel m, boolean b) {
    ButtonModel old = getSelection();
    super.setSelected(m, b);
    firePropertyChange("selection", old, m);
}
Also used : ButtonModel(javax.swing.ButtonModel)

Example 14 with ButtonModel

use of javax.swing.ButtonModel in project vcell by virtualcell.

the class ButtonGroupCivilized method setSelection.

/**
 * This method was created in VisualAge.
 * @param actionCommand java.lang.String
 */
public void setSelection(String actionCommand) {
    // 
    // if selected button does not have this action command, select the first button we find with appropriate action command
    // 
    String currSelectedString = null;
    if (getSelection() != null) {
        currSelectedString = getSelection().getActionCommand();
    }
    if (currSelectedString != null) {
        if (currSelectedString.equals(actionCommand)) {
            return;
        }
    }
    ButtonModel buttonModel = null;
    Enumeration<AbstractButton> buttons = getElements();
    while (buttons.hasMoreElements()) {
        buttonModel = ((AbstractButton) buttons.nextElement()).getModel();
        if (buttonModel.getActionCommand().equals(actionCommand)) {
            setSelection(buttonModel);
            return;
        }
    }
    // 
    if (buttonModel != null) {
        System.out.println("ERROR: button with actionCommand " + actionCommand + " not found");
    }
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Example 15 with ButtonModel

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

the class DialogComponentButtonGroup method updateModel.

/**
 * Transfers the current value from the component into the model.
 */
private void updateModel() {
    // we transfer the value from the button group into the model
    final ButtonModel selectedButton = m_buttonGroup.getSelection();
    final String actionCommand;
    if (selectedButton != null) {
        actionCommand = selectedButton.getActionCommand();
    } else {
        actionCommand = null;
    }
    ((SettingsModelString) getModel()).setStringValue(actionCommand);
}
Also used : ButtonModel(javax.swing.ButtonModel)

Aggregations

ButtonModel (javax.swing.ButtonModel)35 AbstractButton (javax.swing.AbstractButton)12 JToggleButton (javax.swing.JToggleButton)6 BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ButtonGroup (javax.swing.ButtonGroup)3 DefaultListModel (javax.swing.DefaultListModel)3 JButton (javax.swing.JButton)3 JLabel (javax.swing.JLabel)2 JMenu (javax.swing.JMenu)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 DictionaryQueryResults (cbit.vcell.dictionary.DictionaryQueryResults)1 DBFormalSpecies (cbit.vcell.model.DBFormalSpecies)1 AerospikeException (com.aerospike.client.AerospikeException)1 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)1 AlgorithmFactory (edu.cmu.tetrad.algcomparison.algorithm.AlgorithmFactory)1 TsImages (edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.TsImages)1