Class MenuWindow

java.lang.Object
  |
  +--MenuWindow

public class MenuWindow
extends java.lang.Object

A MenuWindow implements a programmerspecifiable menu window. The window contains of a number of buttons, one for each menu alternative specified by the application program. When the user clicks on one of the buttons, the menuItemSelected method is automatically called. The intention is that the MenuWindow class should be used as a super class to another class which overloads the menuItemSelcted method. The overloaded method should contain the Java code to be executed when a menu item is selected. Another possible way of using the class is to modify the MenuWindow class directly, putting the code to be executed when a new message is entered directly in the menuItemSelected method.


Constructor Summary
MenuWindow(int x, int y, java.lang.String title)
          Creates an empty MenuWindow containing no menu items.
 
Method Summary
 void add(java.lang.String menuItem)
          Adds a new menu item to the bottom of the menu.
 void clear()
          Clears the menu from all menu items.
 void destroy()
          Destroys the MenuWindow and frees all resources associated with it.
 void hide()
          Makes the MenuWindow invisible.
 void menuItemSelected(java.lang.String menuItem, int position)
          The menuItemSelected method is called whenever the user clicks on one of the buttons in the menu window.
 void show()
          Makes the MenuWindow visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuWindow

public MenuWindow(int x,
                  int y,
                  java.lang.String title)
Creates an empty MenuWindow containing no menu items. The title displayed in the title bar of the window and the initial position of the window is given by the parameters. Note that the window is initially invisible. You must call the show method in order to display the window.

Note: Depending on which window manager/window system you use, both window title and position might be ignored.

Parameters:
x - the x coordinate of the position of the window
y - the y coordinate of the position of the window
title - a String containing the title to be displayed in the title bar of the window
Method Detail

clear

public void clear()
Clears the menu from all menu items.


add

public void add(java.lang.String menuItem)
Adds a new menu item to the bottom of the menu.

Parameters:
menuItem - A string containing the text to be displayed for this menu item.

destroy

public void destroy()
Destroys the MenuWindow and frees all resources associated with it. The destroy method should be called when the MenuWindow is not needed anymore. Note that it is ILLEGAL to call any method of the MenuWindow object once destroy has been called.


hide

public void hide()
Makes the MenuWindow invisible. Call show to make the window visible again.

See Also:
show()

show

public void show()
Makes the MenuWindow visible. MenuWindows is initially invisible when having been created. To actually make it visible you must call the show method. Call hide to make the window invisible again.

See Also:
hide()

menuItemSelected

public void menuItemSelected(java.lang.String menuItem,
                             int position)
The menuItemSelected method is called whenever the user clicks on one of the buttons in the menu window. The intention is that this method should be overloaded in a subclass to MenuWindow. The default implementation found in the MenuWindow class does nothing.

Parameters:
menuItem - a string containing the text on the selected button
position - the position of the button within the menu. The first button is numbered 0.