| A component that displays a set of hierarchical data as a menu.
Example:
Dialog dlg = new Dialog("Menu Test");
dlg.setBounds(25, 25, 200, 200);
Menu mainMenu = new Menu();
Menu.Item fileItem = new Menu.Item("File");
Menu.Item newItem = new Menu.Item("New");
newItem.setUserObject("You clicked on the File->New menu item");
Menu.Item openItem = new Menu.Item("Open");
openItem.setUserObject("You clicked on the File->Open menu item");
mainMenu.addActionListener(Menu.ACTION_CLICK, new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Menu.Item selectedItem = (Menu.Item) ev.getSource();
MessageBox.confirm("resources/ngLF/system.png", "Menu Test", (String) selectedItem.getUserObject());
}
});
dlg.setMenu(mainMenu);
mainMenu.getRootItem().getChildren().add(fileItem);
fileItem.getChildren().add(newItem);
fileItem.getChildren().add(openItem);
dlg.setVisible(true);
Keyboard Navigation:
author: Joshua J. Gertzen |