Advanced
Java
Services
|
Menu |
Konstruktoren | |
Menu() | Constructs a new menu with an empty label. |
Menu(String label) | Constructs a new menu with the specified label. |
Methoden | |
Returntyp | Name der Methode |
MenuItem | add(MenuItem mi) Adds the specified menu item to this menu. |
void | remove(int index) Removes the menu item at the specified index from this menu. |
void | remove(MenuComponent m) Removes the specified menu item from this menu. |
void | removeAll() |
MenuItem | getItem(int index) Gets the item located at the specified index of this menu. |
int | getItemCount() Get the number of items in this menu. |
void | addSeparator() Adds a separator line, or a hypen, to the menu at the current position. |
// Frame mit einer MenuBar ausstatten MenuBar mb = new MenuBar(); Frame f = new Frame(); f.setMenuBar(mb); // Menu anlegen und aufnehmen Menu dateiMenu = new Menu("Datei"); mb.add(dateiMenu); // Menupunkte erstellen MenuItem openItem = new MenuItem("Öffnen") ; MenuItem exitItem = new MenuItem("Beenden") ; // Menupunkte in Menu aufnehmen dateiMenu.add(openItem); dateiMenu.add(exitItem);