Previous | Next |
The framework provides an abstract base class for each core object in a componentmodel, view, and controlleras well as supporting classes and interfaces. This figure shows the major classes and interfaces:
You create a model for your component by extending the desktop class Model. Model implements the IModel interface, which provides the standard Java interfaces that implement persistence and methods that are used to notify any listeners of changes to the model. You extend the Model class to encapsulate data specific to your component, to provide access to that data, and to define the file extension to be used when instances of your model are saved.
You create a view for your component by extending the class ModelView. ModelView extends the Java AWT class panel, which provides the methods (for example, paint) you override to provide your view's display capabilities. ModelView implements the IView interface, which provides the methods called by the framework to initialize the view, as well as interfaces that ensure that the view is notified of changes to the model or selection. You override these methods to redraw the view as necessary to display those changes. The interfaces are described in Event handling classes.
Typically your view classes will also implement listener interfaces to handle other types of events, both standard Java events (such as mouse and key events) and events specific to your component.
If your component does not have a model, you create its view by extending a Java AWT class such as panel or canvas and implementing the IView interface directly.
You create a controller for your component by extending the class ComponentController. This object initializes the component and contains the model, view, GUIHandler, and selection classes. The ComponentController class does all the initialization for your Java component to work as a bean, application, or applet. This class even provides the showSplashScreen method that you can call if you want to display a custom splash screen as your component launches, and the showExpirationDialog you can call if you want your component to display a special dialog when it reaches an expiration date you establish.
ComponentController also implements the desktop interface ModelSelectionOwner, which it uses to maintain the component's current selection.
ComponentController uses the GUIHandler class to provide default graphical user interface and event management. The GUIHandler class provides:
- A parent frame for hosting the view
- A default menu bar with File, Edit, View, and Help menus
- A default tool bar and tool buttons
- A status bar
- Default handlers for menu item, tool button, and window events
You override methods to implement the functionality you want, assembling the UI and wiring the elements to generate the correct behaviors. GUIHandler is already implemented to handle some standard events, including window activation and focus, and menu item selection. You can extend or modify this event handling, and add interfaces to handle other types of events.
A GUIHandler uses the classes ComponentFrame and Resources to define and manage the component UI:
A ComponentFrame object contains the component's view, and any menu, tool, and status bars associated with it. ComponentFrame extend the class java.awt.Frame.
A Resources object stores and maintains the localizable string resources used when initializing a Bean Works component. Resources extends the class java.util.ListResourceBundle.
Previous | Next |
Copyright ©
Taligent, Inc. 1996 - 1997.
Copyright © IBM Corporation 1996 - 1997.
All Rights Reserved.