use of org.apache.pivot.wtk.MenuHandler 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.MenuHandler in project pivot by apache.
the class ContextMenuTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(ContextMenuTest.class, "context_menu_test.bxml");
bxmlSerializer.bind(this, ContextMenuTest.class);
window.setMenuHandler(new MenuHandler() {
@Override
public boolean configureContextMenu(Component component, Menu menu, int x, int y) {
menu.getSections().add(globalSection);
menu.getSections().add(helpSection);
menu.getSections().add(hoursSection);
return false;
}
});
window.open(display);
}
Aggregations