Class hamlet.AppButton
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class hamlet.AppButton

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----hamlet.AppButton

public class AppButton
extends Applet
Creates an applet that displays a button on the screen. When that button is pushed, it brings up an AppFrame of the class specified by the NAME parameter to the applet. For example
   <applet CODE="AppButton.class" NAME="BlockStacker.BlockStacker">
   </applet>
creates an applet that can bring up a BlockStacker.BlockStacker frame.

The class maintains a static registry of frames that have been previously displayed, each keyed by its class name. Static functions are provided with which a frame can be removed from the registry and with which events can be sent to a frame.

If, when the button is pushed, a frame of that class is already in the registry, that frame is brought to the front of the display and no new frame is created.

See Also:
AppFrame, SendButton

Constructor Index

 o AppButton()

Method Index

 o action(Event, Object)
When the displayed button is clicked, attempts to make, register, and display a frame of the class determined by init.
 o init()
Obtains the NAME parameter, determines the class to which it refers, and displays a button that brings up frames of that class.
 o remove(String)
Removes the object of the specified class from the registry, and stops displaying it.
 o sendMessage(String, String)
Calls the handleMessage method of the AppFrame of the specified class from the registry.

Constructors

 o AppButton
  public AppButton()

Methods

 o init
  public void init()
Obtains the NAME parameter, determines the class to which it refers, and displays a button that brings up frames of that class. If there is no NAME parameter, or if no class by that name can be found, the applet exits.
Overrides:
init in class Applet
 o action
  public synchronized boolean action(Event theEvent,
                                     Object arg)
When the displayed button is clicked, attempts to make, register, and display a frame of the class determined by init. If such a frame has already been registered, brings it to the front instead. If the class can't be instantiated with a nullary constructor, or if the class isn't an AppFrame type, an error message is displayed.
Parameters:
theEvent - Event that triggered the action
arg - Argument associated with the event
Returns:
True if event handled, false otherwise
Overrides:
action in class Component
 o remove
  public static synchronized void remove(String className)
Removes the object of the specified class from the registry, and stops displaying it. Does nothing if no object exists with that class name.
Parameters:
className - The class name of the object to be removed
 o sendMessage
  public static synchronized void sendMessage(String className,
                                              String msg)
Calls the handleMessage method of the AppFrame of the specified class from the registry. Does nothing if no object exists with that class name.
Parameters:
className - The class name of the object to be removed
msg - The argument to be sent along with the event

All Packages  Class Hierarchy  This Package  Previous  Next  Index