Search in sources :

Example 6 with ButtonStateListener

use of org.apache.pivot.wtk.ButtonStateListener 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)

Example 7 with ButtonStateListener

use of org.apache.pivot.wtk.ButtonStateListener in project pivot by apache.

the class CardPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    cardPane = (CardPane) namespace.get("cardPane");
    previousButton = (LinkButton) namespace.get("previousButton");
    nextButton = (LinkButton) namespace.get("nextButton");
    sizeToSelectionCheckbox = (Checkbox) namespace.get("sizeToSelectionCheckbox");
    crossfadeRadioButton = (RadioButton) namespace.get("crossfadeRadioButton");
    horizontalSlideRadioButton = (RadioButton) namespace.get("horizontalSlideRadioButton");
    verticalSlideRadioButton = (RadioButton) namespace.get("verticalSlideRadioButton");
    horizontalFlipRadioButton = (RadioButton) namespace.get("horizontalFlipRadioButton");
    verticalFlipRadioButton = (RadioButton) namespace.get("verticalFlipRadioButton");
    zoomRadioButton = (RadioButton) namespace.get("zoomRadioButton");
    noneRadioButton = (RadioButton) namespace.get("noneRadioButton");
    cardPane.getCardPaneListeners().add(new CardPaneListener() {

        @Override
        public void selectedIndexChanged(CardPane cardPaneArgument, int previousSelectedIndex) {
            updateLinkButtonState();
        }
    });
    previousButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            cardPane.setSelectedIndex(cardPane.getSelectedIndex() - 1);
        }
    });
    nextButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            cardPane.setSelectedIndex(cardPane.getSelectedIndex() + 1);
        }
    });
    ButtonStateListener checkboxStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateCardPane();
        }
    };
    sizeToSelectionCheckbox.getButtonStateListeners().add(checkboxStateListener);
    ButtonStateListener radioButtonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            if (button.isSelected()) {
                updateCardPane();
            }
        }
    };
    crossfadeRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    horizontalSlideRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    verticalSlideRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    horizontalFlipRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    verticalFlipRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    zoomRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    noneRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    updateCardPane();
    updateLinkButtonState();
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) CardPane(org.apache.pivot.wtk.CardPane) LinkButton(org.apache.pivot.wtk.LinkButton) RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener) CardPaneListener(org.apache.pivot.wtk.CardPaneListener)

Aggregations

Button (org.apache.pivot.wtk.Button)7 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)7 RadioButton (org.apache.pivot.wtk.RadioButton)5 Checkbox (org.apache.pivot.wtk.Checkbox)2 ListButton (org.apache.pivot.wtk.ListButton)2 ArrayList (org.apache.pivot.collections.ArrayList)1 Vote (org.apache.pivot.util.Vote)1 State (org.apache.pivot.wtk.Button.State)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 CalendarButton (org.apache.pivot.wtk.CalendarButton)1 CardPane (org.apache.pivot.wtk.CardPane)1 CardPaneListener (org.apache.pivot.wtk.CardPaneListener)1 ColorChooserButton (org.apache.pivot.wtk.ColorChooserButton)1 LinkButton (org.apache.pivot.wtk.LinkButton)1 Sheet (org.apache.pivot.wtk.Sheet)1 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)1 TabPane (org.apache.pivot.wtk.TabPane)1 TabPaneListener (org.apache.pivot.wtk.TabPaneListener)1