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);
}
});
}
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("");
}
});
}
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);
}
});
}
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();
}
Aggregations