use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class JSONViewer method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
bxmlSerializer.getNamespace().put(APPLICATION_KEY, this);
window = (Window) bxmlSerializer.readObject(JSONViewer.class, "json_viewer.bxml");
bxmlSerializer.bind(this);
Label prompt = new Label("Drag or paste JSON here");
prompt.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
prompt.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
promptDecorator.setOverlay(prompt);
treeView.getDecorators().add(promptDecorator);
window.setTitle(WINDOW_TITLE);
window.open(display);
window.requestFocus();
if (System.in.available() > 0) {
JSONSerializer jsonSerializer = new JSONSerializer();
try {
setValue(jsonSerializer.readObject(System.in));
} catch (Exception exception) {
// No-op
}
}
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class MemGame method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(getClass().getResource("memgame.bxml"));
buttons = new PushButton[36];
for (int aux = 0; aux < 36; aux++) {
buttons[aux] = (PushButton) bxmlSerializer.getNamespace().get(String.valueOf(aux + 1));
buttons[aux].getButtonPressListeners().add(this);
}
prepareGame();
window.open(display);
window.setWidth(420);
window.setHeight(420);
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class RowEditorDemo method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
String language = properties.get(LANGUAGE_KEY);
Locale locale = (language == null) ? Locale.getDefault() : new Locale(language);
Resources resources = new Resources(RESOURCE_NAME, locale);
System.out.println("Loaded Resources from: " + resources.getBaseName() + ", for locale " + locale);
// Search for a font that can support the sample string
String title = (String) resources.get("title");
System.out.println("Title from Resources file is: \"" + title + "\"");
// print if the theme has transitions enabled
System.out.println("Theme has transitions enabled: " + Theme.getTheme().isTransitionEnabled());
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(RowEditorDemo.class.getResource("row_editor_demo.bxml"), resources);
window.open(display);
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class ActionMappingTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
Action.getNamedActions().put("action1", new Action() {
@Override
public void perform(Component source) {
Alert.alert(MessageType.INFO, "Action 1 performed.", window);
}
});
Action.getNamedActions().put("action2", new Action() {
@Override
public void perform(Component source) {
Alert.alert(MessageType.INFO, "Action 2 performed.", window);
}
});
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(ActionMappingTest.class, "action_mapping_test.bxml");
window.getActionMappings().add(new Window.ActionMapping(new Keyboard.KeyStroke(Keyboard.KeyCode.B, Keyboard.Modifier.SHIFT.getMask()), "action2"));
window.open(display);
window.requestFocus();
}
use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.
the class ApplicationWithPropertiesTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
System.out.println("application startup(...)");
// initializeProperties(properties);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(ApplicationWithPropertiesTest.class, "application_with_properties_test.bxml");
initializeFields(bxmlSerializer);
window.open(display);
}
Aggregations