Palm API
Beta 2

com.sun.kjava
Class TextField

java.lang.Object
  |
  +--com.sun.kjava.TextField

public class TextField
extends java.lang.Object

This class provides a simple TextField. It creates a thread for the caret to blink, accepts key input (including delete and backspace) and allows for only upper case entry. At present there is no support for Pen selection at all. It needs to be used in conjunction with a Spotlet, as this class does not extend Spotlet and therefore has no event handling itself. You need to get the Spotlet keyDown() method to call this class's handleKeyDown() method. After construction, to get the field "working" call setFocus() this will start the caret. Call loseFocus() to stop the caret when it's all over. *


Constructor Summary
TextField(java.lang.String ttext, int x, int y, int w, int h)
          Create a new TextField
 
Method Summary
 java.lang.String getText()
          Gets the text entered into the textfield
 void handleKeyDown(int key)
          Should be called by Spotlet.keyDown().
 boolean hasFocus()
          Returns whether or not the textfield has focus
 void killCaret()
          Stops the caret thread.
 void loseFocus()
          Stops the caret blinking.
 void paint()
           
 boolean pressed(int x, int y)
          Returns whether or not the x,y position is inside the textfield
 void setFocus()
          Give the textfield "focus".
 void setText(java.lang.String txt)
          Sets the text in the textfield.
 void setUpperCase(boolean flag)
          Set whether or not the textfield should convert everything to upper case
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextField

public TextField(java.lang.String ttext,
                 int x,
                 int y,
                 int w,
                 int h)
Create a new TextField
Parameters:
ttext - The title (label) for the text field
x - x position (upper left)
y - y position (upper left)
w - width (including label)
h - height
Method Detail

setUpperCase

public void setUpperCase(boolean flag)
Set whether or not the textfield should convert everything to upper case
Parameters:
flag - if true then convert chars to upper case

paint

public void paint()

killCaret

public void killCaret()
Stops the caret thread.

setFocus

public void setFocus()
Give the textfield "focus". The registered Spotlet actually has focus. This method kicks off the caret thread to get the caret to blink.

loseFocus

public void loseFocus()
Stops the caret blinking.
See Also:
setFocus()

setText

public void setText(java.lang.String txt)
Sets the text in the textfield. Use this to pre-set (or clear) the value displayed in the textfield.

getText

public java.lang.String getText()
Gets the text entered into the textfield
Returns:
String containing the user's entry

hasFocus

public boolean hasFocus()
Returns whether or not the textfield has focus
See Also:
setFocus(), loseFocus()

pressed

public boolean pressed(int x,
                       int y)
Returns whether or not the x,y position is inside the textfield
See Also:
setFocus(), loseFocus()

handleKeyDown

public void handleKeyDown(int key)
Should be called by Spotlet.keyDown(). Currently this handles backspace (0x08) and delete (0x7f) as backwards delete. Does upper case conversion if necessary.

Submit a bug or feature

The GUI classes provided with this release are NOT part of CLDC, and they will be removed in later releases of this software. Official GUI classes for Java 2 Micro Edition will be defined separately through the Java Community Process and included in J2ME profiles. Java is trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2000 Sun Microsystems, Inc.
901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
All Rights Reserved.