Search in sources :

Example 26 with ButtonModel

use of javax.swing.ButtonModel in project kindergarten by clear-group-ausbildung.

the class NavigationButton method getCurrentColor.

private Color getCurrentColor() {
    ButtonModel m = getModel();
    String foregroundKey = m.isEnabled() ? "NavigationButton.foreground" : "NavigationButton.disabledForeground";
    return RESOURCES.getColor(foregroundKey);
}
Also used : ButtonModel(javax.swing.ButtonModel)

Example 27 with ButtonModel

use of javax.swing.ButtonModel in project CodenameOne by codenameone.

the class ButtonBorder method paintBorder.

public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if (c instanceof AbstractButton) {
        AbstractButton b = (AbstractButton) c;
        ButtonModel model = b.getModel();
        boolean isPressed;
        boolean isRollover;
        boolean isEnabled;
        isPressed = model.isPressed() && model.isArmed();
        isRollover = b.isRolloverEnabled() && model.isRollover();
        isEnabled = b.isEnabled();
        if (!isEnabled) {
            paintDisabled(b, g, x, y, width, height);
        } else {
            if (isPressed) {
                paintPressed(b, g, x, y, width, height);
            } else if (isRollover) {
                paintRollover(b, g, x, y, width, height);
            } else {
                paintNormal(b, g, x, y, width, height);
            }
        }
    }
}
Also used : AbstractButton(javax.swing.AbstractButton) ButtonModel(javax.swing.ButtonModel)

Example 28 with ButtonModel

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

the class ReactionCartoonEditorPanel method initConnections.

private void initConnections() throws Exception {
    for (JToolBarToggleButton modeButton : getModeButtons()) {
        modeButton.addActionListener(this);
    }
    for (JToolBarToggleButton viewButton : getViewButtons()) {
        viewButton.addActionListener(this);
    }
    ButtonModel selection = modeButtonGroup.getSelection();
    if (selection != null) {
        getReactionCartoonTool().setModeString(selection.getActionCommand());
    } else {
        getReactionCartoonTool().setMode(Mode.SELECT);
    }
    getRandomLayoutButton().addActionListener(this);
    getAnnealLayoutButton().addActionListener(this);
    getCircleLayoutButton().addActionListener(this);
    getRelaxerLayoutButton().addActionListener(this);
    getLevellerLayoutButton().addActionListener(this);
    getZoomInButton().addActionListener(this);
    getZoomOutButton().addActionListener(this);
    getGlgLayoutJButton().addActionListener(this);
    getShrinkCanvasButton().addActionListener(this);
    getExpandCanvasButton().addActionListener(this);
    getFloatRequestButton().addActionListener(this);
    getHighlightCatalystsButton().addActionListener(this);
    for (JToolBarToggleButton sizeButton : getSizeOptionsButtons()) {
        sizeButton.addActionListener(this);
    }
}
Also used : ButtonModel(javax.swing.ButtonModel) JToolBarToggleButton(org.vcell.util.gui.JToolBarToggleButton)

Example 29 with ButtonModel

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

the class SpeciesQueryPanel method createDBSpecies.

/**
 * Comment
 */
private void createDBSpecies(javax.swing.event.ListSelectionEvent listSelectionEvent) {
    if (bIgnoreSelection) {
        return;
    }
    if (getDocumentManager() != null) {
        if (!listSelectionEvent.getValueIsAdjusting()) {
            if (!((javax.swing.ListSelectionModel) listSelectionEvent.getSource()).isSelectionEmpty()) {
                try {
                    javax.swing.JList selectionJList = null;
                    if (getCompoundJList().getSelectionModel() == listSelectionEvent.getSource()) {
                        selectionJList = getCompoundJList();
                    } else if (getEnzymeJList().getSelectionModel() == listSelectionEvent.getSource()) {
                        selectionJList = getEnzymeJList();
                    } else if (getProteinJList().getSelectionModel() == listSelectionEvent.getSource()) {
                        selectionJList = getProteinJList();
                    } else {
                        throw new RuntimeException("Unknown ListSelectionModel");
                    }
                    int[] selection = new int[1];
                    selection[0] = selectionJList.getSelectedIndex();
                    DBFormalSpecies[] dbFormalSpecies = jlistData.get(selectionJList);
                    String query = jlistQuery.get(selectionJList);
                    ButtonModel scope = jlistScope.get(selectionJList);
                    boolean bBound = (scope != getDictionaryJRadioButton().getModel());
                    boolean bOnlyUser = (scope == getMyModelJRadioButton().getModel());
                    DictionaryQueryResults dqr = null;
                    if (bBound) {
                        if (getDocumentManager().getUser() == null) {
                            throw new RuntimeException("Query results for 'My Model' can't be bound to null user");
                        }
                        org.vcell.util.document.User user = (bOnlyUser ? getDocumentManager().getUser() : null);
                        dqr = new DictionaryQueryResults(query, user, (DBSpecies[]) dbFormalSpecies, selection);
                    } else {
                        dqr = new DictionaryQueryResults(query, dbFormalSpecies, selection);
                    }
                    setDictionaryQueryResults(dqr);
                    // Clear other selections
                    bIgnoreSelection = true;
                    if (getCompoundJList() != selectionJList) {
                        getCompoundJList().clearSelection();
                    }
                    if (getEnzymeJList() != selectionJList) {
                        getEnzymeJList().clearSelection();
                    }
                    if (getProteinJList() != selectionJList) {
                        getProteinJList().clearSelection();
                    }
                    bIgnoreSelection = false;
                } catch (Exception e) {
                    e.printStackTrace();
                    PopupGenerator.showErrorDialog(this, "Error:\n" + e.getMessage(), e);
                }
            } else {
                setDictionaryQueryResults(null);
            }
        }
    }
}
Also used : JList(javax.swing.JList) DictionaryQueryResults(cbit.vcell.dictionary.DictionaryQueryResults) DBFormalSpecies(cbit.vcell.model.DBFormalSpecies) ButtonModel(javax.swing.ButtonModel)

Example 30 with ButtonModel

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

the class DialogComponentButtonGroup method updateComponent.

/**
 * {@inheritDoc}
 */
@Override
protected void updateComponent() {
    final String val = ((SettingsModelString) getModel()).getStringValue();
    final ButtonModel selectedButton = m_buttonGroup.getSelection();
    final String actionCommand;
    if (selectedButton != null) {
        actionCommand = selectedButton.getActionCommand();
    } else {
        actionCommand = null;
    }
    boolean update;
    if (val == null) {
        update = (actionCommand != null);
    } else {
        update = !val.equals(actionCommand);
    }
    if (update) {
        final Enumeration<AbstractButton> buttons = m_buttonGroup.getElements();
        while (buttons.hasMoreElements()) {
            final AbstractButton button = buttons.nextElement();
            if (button.getActionCommand().equals(val)) {
                button.setSelected(true);
            }
        }
    }
    // also update the enable status
    setEnabledComponents(getModel().isEnabled());
}
Also used : AbstractButton(javax.swing.AbstractButton) 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