example.text
Class Favorites

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Screen
          extended by javax.microedition.lcdui.Form
              extended by example.text.Favorites
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener, javax.microedition.lcdui.ItemCommandListener

public class Favorites
extends javax.microedition.lcdui.Form
implements javax.microedition.lcdui.CommandListener, javax.microedition.lcdui.ItemCommandListener

A Form to handle a Favorites list. The favorites are saved and restored from a RecordStore.


Constructor Summary
Favorites(java.lang.String title)
          Construct a new Favorites Form.
 
Method Summary
 void addFavorite(java.lang.String string, java.lang.String url)
          Add a new Hyperlink StringItem with the go and delete commands.
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable s)
          Handle commands selected by the user.
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Item item)
          Called for Commands on Items.
 java.lang.String getTitle(int index)
          Get the title associated with the item.
 java.lang.String getTitle(javax.microedition.lcdui.Item item)
          Get the title associated with the item.
 java.lang.String getURL(int index)
          Get the url associated with the item.
 java.lang.String getURL(javax.microedition.lcdui.Item item)
          Get the url associated with the item.
 void setCommandListener(javax.microedition.lcdui.CommandListener listener)
          Interpose on the commandListener.
 void setItemCommandListener(javax.microedition.lcdui.ItemCommandListener itemListener)
          Interpose on the itemCommandListener.
 
Methods inherited from class javax.microedition.lcdui.Form
append, append, append, delete, deleteAll, get, getHeight, getWidth, insert, set, setItemStateListener, size
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getTicker, getTitle, isShown, removeCommand, setTicker, setTitle, sizeChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Favorites

public Favorites(java.lang.String title)
Construct a new Favorites Form.

Parameters:
title - the title
Method Detail

setCommandListener

public void setCommandListener(javax.microedition.lcdui.CommandListener listener)
Interpose on the commandListener. This Form will receive all commands from LCDUI and redispatch to the commandListener registered.

Overrides:
setCommandListener in class javax.microedition.lcdui.Displayable
Parameters:
listener - the CommandListener the listener to interpose on

setItemCommandListener

public void setItemCommandListener(javax.microedition.lcdui.ItemCommandListener itemListener)
Interpose on the itemCommandListener. This Form will receive all item commands from LCDUI and redispatch to the ItemCommandListener registered.

Parameters:
itemListener - the ItemCommandListener to interpose on

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable s)
Handle commands selected by the user. Any commands not recognized as being handled by this form are dispatched to the registered command listener.

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener
Parameters:
c - the command
s - the Displayable

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Item item)
Called for Commands on Items.

Specified by:
commandAction in interface javax.microedition.lcdui.ItemCommandListener
Parameters:
c - the Command invoked
item - the item it was invoked on

addFavorite

public void addFavorite(java.lang.String string,
                        java.lang.String url)
Add a new Hyperlink StringItem with the go and delete commands.

Parameters:
string - a string to add to the list
url - of the resource to match the string

getTitle

public java.lang.String getTitle(javax.microedition.lcdui.Item item)
Get the title associated with the item.

Parameters:
item - for which to get the title
Returns:
the title at index

getURL

public java.lang.String getURL(javax.microedition.lcdui.Item item)
Get the url associated with the item.

Parameters:
item - for which to get the URL
Returns:
the URL at index

getTitle

public java.lang.String getTitle(int index)
Get the title associated with the item.

Parameters:
index - for which to get the title
Returns:
the title at index

getURL

public java.lang.String getURL(int index)
Get the url associated with the item.

Parameters:
index - for which to get the URL
Returns:
the URL at index