Search in sources :

Example 41 with ArrayList

use of org.apache.pivot.collections.ArrayList 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)41 List (org.apache.pivot.collections.List)9 Span (org.apache.pivot.wtk.Span)8 Test (org.junit.Test)6 IOException (java.io.IOException)5 ListView (org.apache.pivot.wtk.ListView)5 Point (org.apache.pivot.wtk.Point)5 TableView (org.apache.pivot.wtk.TableView)5 StringWriter (java.io.StringWriter)4 HashMap (org.apache.pivot.collections.HashMap)4 CSVSerializer (org.apache.pivot.serialization.CSVSerializer)4 SerializationException (org.apache.pivot.serialization.SerializationException)4 Vote (org.apache.pivot.util.Vote)4 Component (org.apache.pivot.wtk.Component)4 Form (org.apache.pivot.wtk.Form)4 File (java.io.File)3 FileObject (org.apache.commons.vfs2.FileObject)3 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)3 Bounds (org.apache.pivot.wtk.Bounds)3 ListButton (org.apache.pivot.wtk.ListButton)3