Search in sources :

Example 1 with State

use of org.apache.pivot.wtk.Button.State in project pivot by apache.

the class RepeatableListButtons method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    colorListButton = (ListButton) namespace.get("colorListButton");
    checkboxBoxPane = (BoxPane) namespace.get("checkboxBoxPane");
    ButtonStateListener buttonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, State previousState) {
            if (button.isSelected()) {
                selectedCount++;
            } else {
                selectedCount--;
            }
            applyColorAction.setEnabled(selectedCount > 0);
        }
    };
    ArrayList<String> numbers = new ArrayList<>("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten");
    for (String number : numbers) {
        Checkbox checkbox = new Checkbox(number);
        checkbox.getButtonStateListeners().add(buttonStateListener);
        checkboxBoxPane.add(checkbox);
    }
}
Also used : Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) State(org.apache.pivot.wtk.Button.State) Checkbox(org.apache.pivot.wtk.Checkbox) ArrayList(org.apache.pivot.collections.ArrayList) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Aggregations

ArrayList (org.apache.pivot.collections.ArrayList)1 Button (org.apache.pivot.wtk.Button)1 State (org.apache.pivot.wtk.Button.State)1 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)1 Checkbox (org.apache.pivot.wtk.Checkbox)1 ListButton (org.apache.pivot.wtk.ListButton)1