use of org.apache.pivot.wtk.Action in project pivot by apache.
the class LeakTestWindow method initialize.
@Override
public void initialize(Map<String, Object> arg0, URL arg1, Resources arg2) {
System.out.println("LeakTestWindow initialize(...)\n");
button.setAction(new Action() {
@Override
public void perform(Component component) {
dialogTest++;
System.out.println("Dialog test number " + dialogTest + " at " + new Date());
TestDialog dialog = TestDialog.create();
System.out.println("Opening the dialog");
dialog.open(LeakTestWindow.this);
// Close the dialog straight away
System.out.println("Closing the dialog");
dialog.close();
System.out.println("End of perform()\n");
}
});
}
use of org.apache.pivot.wtk.Action in project pivot by apache.
the class SpinnerFocusTest method startup.
@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
Action action = new Action() {
@Override
public String getDescription() {
return null;
}
@Override
public void perform(final Component source) {
String msg = "Selected: " + spinner.getSelectedItem().toString();
Alert.alert(msg, frame);
spinner.requestFocus();
System.out.println("Focus transferred to spinner");
}
};
Action.getNamedActions().put("buttonAction", action);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("spinner_focus_test.bxml")));
frame.setTitle("Spinner Focus Test");
frame.open(display);
spinner = (Spinner) bxmlSerializer.getNamespace().get("spinner");
spinner.requestFocus();
// action.setEnabled(false);
}
use of org.apache.pivot.wtk.Action in project pivot by apache.
the class MenuBarTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
boxPane.add(new TextInput());
boxPane.add(new TextInput());
boxPane.add(new TextInput());
frame1 = new Frame(boxPane);
frame1.setLocation(50, 50);
frame1.setPreferredSize(320, 240);
frame1.setTitle("Frame 1");
// put this before loading the related bxml, or an
// IllegalArgumentException will be thrown
Action.getNamedActions().put("about", new Action() {
@Override
public void perform(Component source) {
String msg = "Hello from Pivot-" + ApplicationContext.getPivotVersion().toString() + ", running from Java " + // + ApplicationContext.getJVMVersion().toString()
System.getProperty("java.version");
// frame2);
Alert.alert(msg, frame2.getRootOwner());
System.out.println("Help triggered");
}
});
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame2 = (Frame) bxmlSerializer.readObject(MenuBarTest.class, "menu_bar_test.bxml");
frame2.setTitle("Frame 2, from bxml");
bxmlSerializer.bind(this, MenuBarTest.class);
MenuHandler menuHandler = new MenuHandler() {
@Override
public void configureMenuBar(Component component, MenuBar menuBar) {
System.out.println("Configure menu bar: got focus on " + component.getName());
}
@Override
public void cleanupMenuBar(Component component, MenuBar menuBar) {
System.out.println("Clean up menu bar: lost focus on " + component.getName());
}
};
textInput1.setMenuHandler(menuHandler);
textInput2.setMenuHandler(menuHandler);
textInput3.setMenuHandler(menuHandler);
frame1.open(display);
frame2.open(display);
}
use of org.apache.pivot.wtk.Action in project pivot by apache.
the class ContextMenusSampleMenuHandlerAdapter method configureContextMenu.
@Override
public boolean configureContextMenu(Component component, Menu menu, int x, int y) {
Menu.Section menuSection = new Menu.Section();
menu.getSections().add(menuSection);
menuSection.add(new Menu.Item("Do Nothing"));
Menu.Item doNothingMenuItem = new Menu.Item("Do Nothing and disabled");
doNothingMenuItem.setEnabled(false);
menuSection.add(doNothingMenuItem);
Menu.Item whatIsThisMenuItem = new Menu.Item("What is this?");
whatIsThisMenuItem.setAction(new Action() {
@Override
public void perform(Component source) {
String description = (descendant != null) ? (String) descendant.getUserData().get("description") : "empty";
String message = "This is a " + description + " description.";
System.out.println("perform: " + message);
}
});
menuSection.add(whatIsThisMenuItem);
Menu.Item nullActionMenuItem = new Menu.Item("Item with null action");
nullActionMenuItem.setAction((Action) null);
menuSection.add(nullActionMenuItem);
Menu.Item disabledActionMenuItem = new Menu.Item("Item with disabled action");
disabledActionMenuItem.setAction(new Action() {
@Override
public void perform(Component source) {
System.out.println("in perform");
}
});
disabledActionMenuItem.getAction().setEnabled(false);
menuSection.add(disabledActionMenuItem);
return false;
}
use of org.apache.pivot.wtk.Action 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();
}
Aggregations