Example usage for javax.swing ButtonModel setArmed

List of usage examples for javax.swing ButtonModel setArmed

Introduction

In this page you can find the example usage for javax.swing ButtonModel setArmed.

Prototype

public void setArmed(boolean b);

Source Link

Document

Marks the button as armed or unarmed.

Usage

From source file:JToggleButtonMenuItem.java

public void menuSelectionChanged(boolean isIncluded) {
    ButtonModel model = getModel();
    // Only change armed state if different
    if (model.isArmed() != isIncluded) {
        model.setArmed(isIncluded);
    }/* w ww .  ja v a 2s  . c  o m*/

    if (isIncluded) {
        savedForeground = getForeground();
        if (!savedForeground.equals(Color.BLUE)) {
            setForeground(Color.BLUE);
        } else {
            // In case foreground blue, use something different
            setForeground(Color.RED);
        }
    } else {
        setForeground(savedForeground);
        // If null, get foreground from installed look and feel
        if (savedForeground == null) {
            updateUI();
        }
    }
}

From source file:ToggleSample.java

public void menuSelectionChanged(boolean isIncluded) {
    ButtonModel model = getModel();
    // only change armed state if different
    if (model.isArmed() != isIncluded) {
        model.setArmed(isIncluded);
    }/*from  www.  j av a 2 s  .com*/

    if (isIncluded) {
        savedForeground = getForeground();
        if (!savedForeground.equals(Color.blue)) {
            setForeground(Color.blue);
        } else {
            // In case foreground blue, use something different
            setForeground(Color.red);
        }
    } else {
        setForeground(savedForeground);
        // if null, get foreground from installed look and feel
        if (savedForeground == null) {
            updateUI();
        }
    }
}