menu
Class Page

java.lang.Object
  |
  +--menu.Page
Direct Known Subclasses:
MenuPage, URLPage

public abstract class Page
extends java.lang.Object

A Page is the basic element in a hierarchy of displayable pages. This abstract class is extended to define specific behavior by specific types of pages.

If a subclass wishes to have a separate thread, it must implement the Runnable interface. The separate thread is created and started by calling the start() method of Page.

$Id: Page.java,v 1.4 2003/01/21 00:22:08 finson Exp $


Field Summary
protected  boolean run
          Set to true while the dynamic content thread is running.
protected  java.lang.Thread theThread
          The Thread object representing the dynamic content thread.
 
Constructor Summary
Page(java.lang.String label, java.lang.String title, javax.microedition.lcdui.Image icon)
          Initialize a new Page object using the supplied parameters.
 
Method Summary
abstract  int doCommandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
          Process the user command and return an integer value telling the PageMgr what to do next.
abstract  javax.microedition.lcdui.Displayable getDisplayable()
          Return the Displayable object for this Page, completely filled in and ready to display.
 javax.microedition.lcdui.Image getIcon()
          Return Page icon.
 java.lang.String getLabel()
          Return Page label.
 Page getLinkedPage()
          Return the Page that this Page feels should be the next page to be displayed.
 Page getPrevious()
          Return pointer to previous page visited.
 java.lang.String getTitle()
          Return Page title.
 void setPrevious(Page p)
          Set pointer to previous page visited.
 void start()
          Create a separate thread and start it running.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

run

protected boolean run
Set to true while the dynamic content thread is running. Set to false to indicate that the dynamic content thread should exit ASAP and should definitely not touch anything like the screen. Once this is set to false, the dynamic content thread is no longer welcome in Dodge City.


theThread

protected java.lang.Thread theThread
The Thread object representing the dynamic content thread. The content thread sets this to null to acknowledge that it is exiting as requested. This means that if the content thread does not exit gracefully and fails to reset theThread, then the page will not be able to reload.

Constructor Detail

Page

public Page(java.lang.String label,
            java.lang.String title,
            javax.microedition.lcdui.Image icon)
Initialize a new Page object using the supplied parameters.

Parameters:
label - short label for this page (as might be used in a menu). Must not be null.
title - longer label for this page (as might be used in a screen title).
icon - small icon for this page (as might be used in a toolbar or menu.
Method Detail

getDisplayable

public abstract javax.microedition.lcdui.Displayable getDisplayable()
Return the Displayable object for this Page, completely filled in and ready to display.

Returns:
the appropriate Displayable object for this Page

doCommandAction

public abstract int doCommandAction(javax.microedition.lcdui.Command c,
                                    javax.microedition.lcdui.Displayable d)
Process the user command and return an integer value telling the PageMgr what to do next. This method handles the details of a command for a page, while the commandAction method in the PageMgr handles the general responsibility of switching displays.

Parameters:
c - a Command object identifying the command.
d - the Displayable on which this event has occurred
Returns:
a pageAction code, selected from the public fields defined by PageMgr.

start

public void start()
Create a separate thread and start it running. The run method of the concrete class that extends Page is the run method that is used. The concrete class must implement the Runnable interface to let us know that the run() method exists.

Throws:
java.lang.ClassCastException - if the concrete class does not implement the Runnable interface.
java.lang.IllegalStateException - if there is a Page thread already running. This means that if a thread hangs on some long-term blocking call and the user cancels out of it and tries the same page again before the thread actually exits, then the midlet will die with this error unless the caller of start() catches the exception.

getLinkedPage

public Page getLinkedPage()
Return the Page that this Page feels should be the next page to be displayed. This method is called by the PageMgr after doCommandAction returns PageMgr.LINK as the pageAction value. If the subclass can return this pageAction, then it must override this implementation of getLinkedPage with an appropriate implementation that does not throw an Exception.

Returns:
Page the next Page to be displayed
Throws:
java.lang.IllegalStateException - this implementation always throws this exception

getLabel

public java.lang.String getLabel()
Return Page label.

Returns:
Page label

getTitle

public java.lang.String getTitle()
Return Page title.

Returns:
Page title

getIcon

public javax.microedition.lcdui.Image getIcon()
Return Page icon.

Returns:
Page icon

getPrevious

public Page getPrevious()
Return pointer to previous page visited.

Returns:
previous Page

setPrevious

public void setPrevious(Page p)
Set pointer to previous page visited.

Parameters:
p - previous Page