|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--brf.j2me.dynaworks.Page
Abstract base class for application pages.
Page objects allows the application developer to use more then one screen page in an application. Each page has its own controls and event-handling.
User interface elements
GUI components can be added to a page by passing a reference to the component
(derived from UserWidget) to the "add()" method. This is normally done in the
constructor of the implementing class. The Page class then takes care of the
control (repaint, event handling etc.) for all the controls added to it.
Event handling
A page receives a reference to an EventQueue instance that "feeds" the
page with events. The page class handles or dispatches these events to
the UserWidget controls or passes the directly to the 'handleEvent()'
method in case they are posted 'ActionEvents'.
User interface elements emit events of type ActionEvent that are passed to the "handleEvent()" method of implementing classes. This is the place to code the interface logic of your page and to react to user interaction.
If you want to pass in an ActionEvent to the Page object from inside your application logic, you can use the "postEvent()" method to post an event for processing in the EventQueue. There can be any number of posted events at a time.
Application-wide data store
Pages have access to a application-wide data store that can be used to share
data across pages. Data objects are stored in the dictionary by name; any
Java object can be used as a data object in this object store. You can add,
retrieve and remove data objects from the dictionary with the methods
"addVariable()", "getVariable()" and "removeVariable()".
Linking to another page on exit
Every page is identified by a unique name. If the page "terminates" (e.g.
the user pressed the "exit" button) it passes a String back to the
Application object. This string tells the Application object what page to
show next. The following rules apply to the String object:
1.) If the String is empty (or a "null" reference) than there is no request to load another page. The Application exits in case the call stack (see 2) is empty; otherwise the call stack is popped and the retrieved page is displayed.
2.) If the String starts with a '@' character, the name following that character are treated as the name of a page. This page is then loaded and the name of the "calling" page is pushed onto a call stack. This allows nested pages.
3.) If the String is a simple name, the corresponding page is loaded and activated (displayed)
To pass back this String reference, any implementing class must use the "exit()" method of the Page class to terminate processing; the name of the page (or the "null" reference) is passed into the "exit()" method as an argument.
Application,
UserWidget,
DataDictionary,
Event,
EventQueue| Field Summary | |
protected static Audio |
audio
reference to physical audio. |
protected static Graphics |
canvas
reference to physical screen. |
protected java.util.Vector |
comps
list of docked components. |
protected DataDictionary |
data
Reference to active data dictionary. |
protected UserWidget |
focus
reference to widget that holds the focus. |
protected java.lang.Object |
modalLock
|
protected PopupWidget |
modalWidget
reference to popup widget. |
protected java.lang.String |
name
name of the page. |
protected java.lang.String |
nextpage
name of page to follow. |
protected EventQueue |
queue
reference to event queue. |
protected boolean |
running
Is the task active? |
| Constructor Summary | |
Page(java.lang.String name)
constructor. |
|
| Method Summary | |
(package private) static void |
static initialization of class. |
boolean |
add(UserWidget comp)
add a user interface element. |
protected boolean |
addVariable(java.lang.String key,
java.lang.Object value)
add a data object to the dictionary. |
void |
dispatchEvent(Event e)
Dispatch events: ActionEvents are passed directly to the 'handleEvent()' method of the implementing class whereas 'normal' events are actually dispatched to the user widgets. |
void |
exit(java.lang.String nextpage)
leave the page. |
java.lang.String |
getName()
get the name of the page. |
protected java.lang.Object |
getVariable(java.lang.String name)
retrieve a data object from the dictionary. |
abstract boolean |
handleEvent(ActionEvent e)
handle events from user interface elements. |
void |
keyDown(int keyCode)
The user has entered a keystroke. |
void |
paint()
All user interface elements have to be repainted. |
void |
penDown(int x,
int y)
User touches the canvas at the given coordinates. |
void |
penMove(int x,
int y)
User moves on the canvas to the given coordinates. |
void |
penUp(int x,
int y)
User lifts pen from the canvas at the given coordinates. |
java.lang.String |
perform(EventQueue queue,
boolean clear)
this is the page entry point. |
protected boolean |
postEvent(Event e)
Post an Event. |
protected boolean |
removeVariable(java.lang.String name)
remove a data object. |
int |
run(PopupWidget comp)
running a modal popup widget. |
DataDictionary |
setData(DataDictionary data)
assign the data store. |
void |
sysKeyDown(int keyCode)
The user has pressed a system key. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
| Field Detail |
protected java.lang.String name
protected static Graphics canvas
protected static Audio audio
protected PopupWidget modalWidget
protected java.lang.Object modalLock
protected boolean running
protected UserWidget focus
protected EventQueue queue
protected DataDictionary data
protected java.util.Vector comps
protected java.lang.String nextpage
| Constructor Detail |
public Page(java.lang.String name)
name - String - name of the page.| Method Detail |
static void()
Graphics,
Audiopublic DataDictionary setData(DataDictionary data)
This method is usually called by the Application object when a page is added to the application. It sets the application specific data dictionary that can be used by pages of one application to share information.
data - DataDictionary - data store for application variables.DataDictionaryprotected java.lang.Object getVariable(java.lang.String name)
name - String - name of the variable.DataDictionary,
addVariable(java.lang.String, java.lang.Object),
removeVariable(java.lang.String)
protected boolean addVariable(java.lang.String key,
java.lang.Object value)
key - String - name of the variable.value - Object - data objectDataDictionary,
getVariable(java.lang.String),
removeVariable(java.lang.String)protected boolean removeVariable(java.lang.String name)
name - String - name of the variable.DataDictionary,
getVariable(java.lang.String),
addVariable(java.lang.String, java.lang.Object)public abstract boolean handleEvent(ActionEvent e)
e - ActionEvent - event passed to system.ActionEvent,
postEvent(brf.j2me.dynaworks.env.Event)protected boolean postEvent(Event e)
e - Event - event to be posted.Event,
EventQueue,
handleEvent(brf.j2me.dynaworks.ActionEvent)public void dispatchEvent(Event e)
e - Event - event to be dispatched.ActionEvent,
Event,
EventQueue
public java.lang.String perform(EventQueue queue,
boolean clear)
clear - boolean - clear the screen.public void exit(java.lang.String nextpage)
nextpage - String - name of the next page to be loaded.public int run(PopupWidget comp)
comp - PopupWidget - user interface control to be displayed.PopupWidgetpublic boolean add(UserWidget comp)
comp - UserWidget - user interface control to be added.UserWidgetpublic java.lang.String getName()
public void paint()
public void penDown(int x,
int y)
x - int - coordinatey - int - coordinate
public void penMove(int x,
int y)
x - int - coordinatey - int - coordinate
public void penUp(int x,
int y)
x - int - coordinatey - int - coordinatepublic void keyDown(int keyCode)
keyCode - int - keystroke entered.public void sysKeyDown(int keyCode)
keyCode - int - key pressed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||