Example usage for com.jgoodies.binding.adapter Bindings bind

List of usage examples for com.jgoodies.binding.adapter Bindings bind

Introduction

In this page you can find the example usage for com.jgoodies.binding.adapter Bindings bind.

Prototype

public static void bind(AbstractButton toggleButton, ValueModel valueModel, Object selectedValue,
        Object deselectedValue) 

Source Link

Document

Binds a JToggleButton to the given ValueModel in check box style.

Usage

From source file:org.seasar.golf.binding.FormBindingManager.java

License:Apache License

public void Bind(JComponent jc, ValueModel vm, Object choice, boolean immed) {

    if (jc instanceof DoubleField) {
        GolfBindings.bind((DoubleField) jc, vm, ((DoubleField) jc).getDocument(), !immed);
    } else if (jc instanceof LongField) {
        GolfBindings.bind((LongField) jc, vm, ((LongField) jc).getDocument(), !immed);
    }/*from www .j  a v a2 s .  com*/

    else if (jc instanceof JTextField) {
        Bindings.bind((JTextField) jc, vm, ((JTextField) jc).getDocument(), !immed);
    } else if (jc instanceof JCheckBox) {
        Bindings.bind((JCheckBox) jc, vm);
    } else if (jc instanceof JCheckBoxMenuItem) {
        Bindings.bind((JCheckBoxMenuItem) jc, vm);
    } else if (jc instanceof JColorChooser) {
        Bindings.bind((JColorChooser) jc, vm);
    } else if (jc instanceof JFormattedTextField) {
        Bindings.bind((JFormattedTextField) jc, vm);
    } else if (jc instanceof JLabel) {
        Bindings.bind((JLabel) jc, vm);
    } else if (jc instanceof JTextArea) {
        Bindings.bind((JTextArea) jc, vm, ((JTextArea) jc).getDocument(), !immed);
    } else if (jc instanceof JRadioButton) {
        if (choice == null) {
            throw (new IllegalArgumentException("choice not set"));
        }
        Bindings.bind((JRadioButton) jc, vm, choice);
    } else if (jc instanceof JRadioButtonMenuItem) {
        if (choice == null) {
            throw (new IllegalArgumentException("choice not set"));
        }
        Bindings.bind((JRadioButtonMenuItem) jc, vm, choice);
    } else if (jc instanceof JComboBox) {
        ((SelectionInList) vm).setListModel(((JComboBox) jc).getModel());
        Bindings.bind((JComboBox) jc, (SelectionInList) vm);
    } else if (jc instanceof JList) {
        ((SelectionInList) vm).setListModel(((JList) jc).getModel());
        Bindings.bind((JList) jc, (SelectionInList) vm);
    } else {

        throw (new UnsupportedBindingClassException(jc.getClass().toString()));
    }
}