com.sun.kjava
Class Spotlet

java.lang.Object
  |
  +--com.sun.kjava.Spotlet
Direct Known Subclasses:
Dialog, HelpDisplay

public class Spotlet
extends java.lang.Object

This class provides callbacks for event handling. Applications extend this class and override the relevant event handling methods. An application may use more than one Spotlet object, but at most one Spotlet can have the focus at any one time. That is, events will only trigger the callbacks of one Spotlet at any given time, the Spotlet with the current focus.

To become the focus, a Spotlet invokes the register method which also removes the focus from the previously registered Spotlet (if any).


Field Summary
static int CALCICON
          Constant for the calculator icon.
static int KEY_HARD1
          Constants for the other Palm system "hard" keys.
static int KEY_HARD2
           
static int KEY_HARD3
           
static int KEY_HARD4
           
static int KEY_POWER
           
static int MENUICON
          Constant for the menu icon.
static int NO_EVENT_OPTIONS
          Constants for the eventOptions of register().
static int PAGEDOWN
           
static int PAGEUP
          Constants for the page up/down "hard" keys.
static int WANT_SYSTEM_KEYS
           
 
Constructor Summary
Spotlet()
           
 
Method Summary
 void beamReceive(byte[] data)
          This method is used for receiving packets of data via infrared from other Palm devices.
static boolean beamSend(byte[] data)
          This method is used for beaming data packets via infrared to another Palm device.
 void dispatch(int event, java.io.DataInput in)
           
static java.lang.String getFlashID()
          This method is used to get the flashID of the Palm device.
 void keyDown(int keyCode)
          This method is invoked if the user presses either of the page up or page down hard keys, taps the calculator or menu icon, or enters a character (e.g.
 void penDown(int x, int y)
          This method is invoked if the user places the pen on the display.
 void penMove(int x, int y)
          This method is invoked if the user moves the pen over the display.
 void penUp(int x, int y)
          This method is invoked if the user removes the pen from the display.
 void register(int eventOptions)
          Register the event handlers of this object.
static void setPalmEventOptions(int eventOptions)
           
 void unknownEvent(int event, java.io.DataInput in)
          Catchall routine
 void unregister()
          Unregister the event handlers of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAGEUP

public static final int PAGEUP
Constants for the page up/down "hard" keys.

PAGEDOWN

public static final int PAGEDOWN

KEY_HARD1

public static final int KEY_HARD1
Constants for the other Palm system "hard" keys.

KEY_HARD2

public static final int KEY_HARD2

KEY_HARD3

public static final int KEY_HARD3

KEY_HARD4

public static final int KEY_HARD4

KEY_POWER

public static final int KEY_POWER

CALCICON

public static final int CALCICON
Constant for the calculator icon.

MENUICON

public static final int MENUICON
Constant for the menu icon.

NO_EVENT_OPTIONS

public static final int NO_EVENT_OPTIONS
Constants for the eventOptions of register().

WANT_SYSTEM_KEYS

public static final int WANT_SYSTEM_KEYS
Constructor Detail

Spotlet

public Spotlet()
Method Detail

dispatch

public void dispatch(int event,
                     java.io.DataInput in)
              throws java.io.IOException

unknownEvent

public void unknownEvent(int event,
                         java.io.DataInput in)
Catchall routine

register

public void register(int eventOptions)
Register the event handlers of this object. This effectively makes this Spotlet the focus for event handling. A side effect this is that all previously registered handlers (if any) are unregistered and the Spotlet to which they belong loses the focus.
Parameters:
eventOptions - one of NO_EVENT_OPTIONS or WANT_SYSTEM_KEYS

setPalmEventOptions

public static void setPalmEventOptions(int eventOptions)

unregister

public void unregister()
Unregister the event handlers of this object. It is only necessary to use this method when not transferring the focus from this Spotlet to another one via a subsequent call to register. If this Spotlet does not currently have the focus, this method does nothing.

penDown

public void penDown(int x,
                    int y)
This method is invoked if the user places the pen on the display.
Parameters:
x - the x coordinate of the point at which the pen was placed
y - the y coordinate of the point at which the pen was placed

penUp

public void penUp(int x,
                  int y)
This method is invoked if the user removes the pen from the display.
Parameters:
x - the x coordinate of the point from which the pen was removed
y - the y coordinate of the point from which the pen was removed

penMove

public void penMove(int x,
                    int y)
This method is invoked if the user moves the pen over the display.
Parameters:
x - the x coordinate of the destination point of the move
y - the y coordinate of the destination point of the move

keyDown

public void keyDown(int keyCode)
This method is invoked if the user presses either of the page up or page down hard keys, taps the calculator or menu icon, or enters a character (e.g. via Graffiti). If it is one of the hard key presses, then it will match one of the corresponding constants defined in this class.
Parameters:
keyCode - the code of the key the user entered

beamReceive

public void beamReceive(byte[] data)
This method is used for receiving packets of data via infrared from other Palm devices. The data that is read is received in a byte array that is allocated automatically by the virtual machine.

beamSend

public static boolean beamSend(byte[] data)
This method is used for beaming data packets via infrared to another Palm device. IMPORTANT: Unlike the methods above, this method is not an event handler. Rather, you call this method explicitly to beam data to another device. The other device must have registered a beamReceive handler in its current Spotlet to receive data.
Returns:
true if beaming succeeded, false otherwise.

getFlashID

public static java.lang.String getFlashID()
This method is used to get the flashID of the Palm device. IMPORTANT: Unlike the methods above, this method is not an event handler.
Returns:
a String containing the flashID.