Search in sources :

Example 36 with PushButton

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

the class RadioButtons method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    selectButton = (PushButton) namespace.get("selectButton");
    // Get a reference to the button group
    final ButtonGroup numbersGroup = (ButtonGroup) namespace.get("numbers");
    // Add a button press listener
    selectButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            String message = "You selected \"" + numbersGroup.getSelection().getButtonData() + "\".";
            Alert.alert(MessageType.INFO, message, RadioButtons.this);
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) ButtonGroup(org.apache.pivot.wtk.ButtonGroup) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button)

Example 37 with PushButton

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

the class DataBinding method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    form = (Form) namespace.get("form");
    loadJavaButton = (PushButton) namespace.get("loadJavaButton");
    loadJSONButton = (PushButton) namespace.get("loadJSONButton");
    clearButton = (PushButton) namespace.get("clearButton");
    sourceLabel = (Label) namespace.get("sourceLabel");
    loadJavaButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            form.load(new BeanAdapter(CONTACT));
            sourceLabel.setText("Java");
        }
    });
    loadJSONButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            JSONSerializer serializer = new JSONSerializer();
            try (InputStream inputStream = getClass().getResourceAsStream("contact.json")) {
                form.load(serializer.readObject(inputStream));
                sourceLabel.setText("JSON");
            } catch (Exception exception) {
                System.err.println(exception);
            }
            button.setEnabled(true);
        }
    });
    clearButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            form.clear();
            sourceLabel.setText("");
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) InputStream(java.io.InputStream) BeanAdapter(org.apache.pivot.beans.BeanAdapter) JSONSerializer(org.apache.pivot.json.JSONSerializer)

Example 38 with PushButton

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

the class ExpenseSheet method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resource) {
    this.resources = resource;
    dateSpinner = (Spinner) namespace.get("dateSpinner");
    typeListButton = (ListButton) namespace.get("typeListButton");
    amountTextInput = (TextInput) namespace.get("amountTextInput");
    cancelButton = (PushButton) namespace.get("cancelButton");
    okButton = (PushButton) namespace.get("okButton");
    cancelButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            close(false);
        }
    });
    okButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            close(true);
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton)

Example 39 with PushButton

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

the class Meters method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    meter = (Meter) namespace.get("meter");
    progressButton = (PushButton) namespace.get("progressButton");
    progressButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            if (sampleTask == null) {
                // Create and start the simulated task; wrap it in a
                // task adapter so the result handlers are called on the
                // UI thread
                sampleTask = new SampleTask();
                sampleTask.execute(new TaskAdapter<>(new TaskListener<Void>() {

                    @Override
                    public void taskExecuted(Task<Void> task) {
                        reset();
                    }

                    @Override
                    public void executeFailed(Task<Void> task) {
                        reset();
                    }

                    private void reset() {
                        // Reset the meter and button
                        sampleTask = null;
                        meter.setPercentage(0);
                        updateProgressButton();
                    }
                }));
            } else {
                // Cancel the task
                sampleTask.abort();
            }
            updateProgressButton();
        }
    });
    updateProgressButton();
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) TaskAdapter(org.apache.pivot.wtk.TaskAdapter)

Aggregations

PushButton (org.apache.pivot.wtk.PushButton)39 Button (org.apache.pivot.wtk.Button)29 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)23 Window (org.apache.pivot.wtk.Window)9 BoxPane (org.apache.pivot.wtk.BoxPane)8 Component (org.apache.pivot.wtk.Component)6 GradientPaint (java.awt.GradientPaint)5 ListButton (org.apache.pivot.wtk.ListButton)5 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)4 Path (org.apache.pivot.collections.Sequence.Tree.Path)3 Checkbox (org.apache.pivot.wtk.Checkbox)3 Frame (org.apache.pivot.wtk.Frame)3 ListView (org.apache.pivot.wtk.ListView)3 Sheet (org.apache.pivot.wtk.Sheet)3 TreeView (org.apache.pivot.wtk.TreeView)3 TreeViewSelectionListener (org.apache.pivot.wtk.TreeViewSelectionListener)3 TreeBranch (org.apache.pivot.wtk.content.TreeBranch)3 File (java.io.File)2 TaskExecutionException (org.apache.pivot.util.concurrent.TaskExecutionException)2 Alert (org.apache.pivot.wtk.Alert)2