Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit
Class TextField

java.lang.Object
  extended by com.sun.dtv.lwuit.Component
      extended by com.sun.dtv.lwuit.TextArea
          extended by com.sun.dtv.lwuit.TextField
All Implemented Interfaces:
Animation, StyleListener, Animated

public class TextField
extends TextArea

Allows in place editing using a lightweight API without necessarily moving to the external native text box. The main drawback in this approach is that editing can't support features such as T9 and might not have the same key mapping or behavior of the native text input.

Notice that due to limitations of text area and text field input modes in text area aren't properly supported since they won't work properly across devices. To limit input modes please use the setInputModeOrder method. All constants declared in TextArea are ignored with the exception of PASSWORD.


Field Summary
 
Fields inherited from class com.sun.dtv.lwuit.TextArea
ANY, DECIMAL, EMAILADDR, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD, NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, UNEDITABLE, URL
 
Fields inherited from class com.sun.dtv.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
Constructor Summary
TextField()
          Default constructor.
TextField(int columns)
          Construct a text field with space reserved for columns.
TextField(String text)
          Construct text field.
TextField(String text, int columns)
          Construct text field.
 
Method Summary
 void addDataChangeListener(DataChangedListener d)
          Adds a listener for data change events it will be invoked for every change made to the text field.
static void addInputMode(String name, Hashtable values, boolean firstUpcase)
          Adds a new input mode hashtable with the given name and set of values.
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
 int getCommitTimeout()
          The amount of time in milliseconds it will take for a change to get committed into the field.
 int getCursorBlinkTimeOff()
          The amount of time in milliseconds in which the cursor is invisible.
 int getCursorBlinkTimeOn()
          The amount of time in milliseconds in which the cursor is visible.
 int getCursorPosition()
          Returns the position of the cursor.
static String[] getDefaultInputModeOrder()
          Returns the order in which input modes are toggled by default.
 String getInputMode()
          Returns the currently selected input mode.
 String[] getInputModeOrder()
          Returns the order in which input modes are toggled.
static char[] getSymbolTable()
          Returns the symbol table for the device.
 boolean isPendingCommit()
          Returns true if the text field is waiting for a commit on editing.
static boolean isQwertyAutoDetect()
          Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly.
static boolean isQwertyDevice()
          The default value for the qwerty flag so it doesn't need setting for every text field individually.
 boolean isQwertyInput()
          True is this is a qwerty device or a device that is currently in qwerty mode.
 boolean isReplaceMenu()
          Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.
static boolean isReplaceMenuDefault()
          Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.
 boolean isUseSoftkeys()
          When set to true softkeys are used to enable delete functionality.
 void keyPressed(int keyCode)
          If this Component is focused, the key pressed event will call this method.
 void keyReleased(int keyCode)
          If this Component is focused, the key released event will call this method.
 void paint(Graphics g)
          This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
 void pointerReleased(int x, int y)
          If this Component is focused, the pointer released event will call this method.
 void removeDataChangeListener(DataChangedListener d)
          Removes the listener for data change events.
static void setClearText(String text)
          Set the text that should appear on the clear soft key.
 void setCommitTimeout(int commitTimeout)
          The amount of time in milliseconds it will take for a change to get committed into the field.
 void setCursorBlinkTimeOff(int time)
          The amount of time in milliseconds in which the cursor is invisible.
 void setCursorBlinkTimeOn(int time)
          The amount of time in milliseconds in which the cursor is visible.
 void setCursorPosition(int pos)
          Set the position of the cursor.
static void setDefaultInputModeOrder(String[] order)
          Sets the order in which input modes are toggled by default and allows disabling/hiding an input mode.
 void setEditable(boolean b)
          Sets this text area to be editable or readonly.
 void setInputMode(String mode)
          Sets the current selected input mode matching one of the existing input modes.
 void setInputModeOrder(String[] order)
          Sets the order in which input modes are toggled and allows disabling/hiding an input mode.
static void setQwertyAutoDetect(boolean v)
          Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly.
static void setQwertyDevice(boolean v)
          The default value for the qwerty flag so it doesn't need setting for every text field individually.
 void setQwertyInput(boolean qwerty)
          Set this device to operate in or no longer operate in qwerty mode.
 void setReplaceMenu(boolean replaceMenu)
          Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.
static void setReplaceMenuDefault(boolean replaceMenu)
          Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.
static void setSymbolTable(char[] table)
          Sets the symbol table to show when the user clicks the symbol table key.
static void setT9Text(String text)
          Set the text that should appear on the T9 soft key.
 void setText(String text)
          Sets the text within this text area.
 void setUseSoftkeys(boolean useSoftkeys)
          When set to true softkeys are used to enable delete functionality.
 
Methods inherited from class com.sun.dtv.lwuit.TextArea
addActionListener, getColumns, getConstraint, getLines, getMaxSize, getRows, getRowsGap, getText, getTextAt, getUnsupportedChars, isAutoDegradeMaxSize, isEditable, isGrowByContent, isScrollableY, removeActionListener, setAutoDegradeMaxSize, setColumns, setConstraint, setDefaultMaxSize, setGrowByContent, setMaxSize, setRows, setRowsGap, setUnsupportedChars
 
Methods inherited from class com.sun.dtv.lwuit.Component
addFocusListener, calcPreferredSize, contains, deinitialize, getAbsoluteX, getAbsoluteY, getAnimationMode, getBaseline, getBaselineResizeBehavior, getBottomGap, getBounds, getClientProperty, getComponentForm, getDelay, getHeight, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPosition, getPreferredSize, getRepetitionMode, getScrollAnimationSpeed, getScrollX, getScrollY, getSideGap, getStyle, getUIID, getWidth, getX, getY, handlesInput, hasFocus, initialize, isEnabled, isFocusable, isFocusPainted, isInitialized, isRunning, isScrollableX, isScrollVisible, isSmoothScrolling, isVisible, jumpTo, keyRepeated, longKeyPress, paintBackgrounds, paintComponent, paintComponent, pointerDragged, pointerPressed, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, setAnimationMode, setCellRenderer, setDelay, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredSize, setRepetitionMode, setScrollAnimationSpeed, setScrollX, setScrollY, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setStyle, setUIID, setVisible, setWidth, setX, setY, start, stop, styleChanged, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextField

public TextField()
Default constructor.


TextField

public TextField(int columns)
Construct a text field with space reserved for columns.

Parameters:
columns - number of columns

TextField

public TextField(String text)
Construct text field.

Parameters:
text - content of textfield

TextField

public TextField(String text,
                 int columns)
Construct text field.

Parameters:
text - content of text field
columns - number of columns
Method Detail

setClearText

public static void setClearText(String text)
Set the text that should appear on the clear soft key.

Parameters:
text - the text for clear soft key

setT9Text

public static void setT9Text(String text)
Set the text that should appear on the T9 soft key.

Parameters:
text - the text for T9 soft key

isPendingCommit

public boolean isPendingCommit()
Returns true if the text field is waiting for a commit on editing.

Returns:
true if there is a pending commit, false otherwise

setCommitTimeout

public void setCommitTimeout(int commitTimeout)
The amount of time in milliseconds it will take for a change to get committed into the field.

Parameters:
commitTimeout - indicates the amount of time that should elapse for a commit to automatically occur
See Also:
getCommitTimeout()

getCommitTimeout

public int getCommitTimeout()
The amount of time in milliseconds it will take for a change to get committed into the field.

Returns:
the amount of time that should elapse for a commit to automatically occur
See Also:
setCommitTimeout(int)

setInputMode

public void setInputMode(String mode)
Sets the current selected input mode matching one of the existing input modes.

Parameters:
mode - the display name of the input mode by default the following modes are supported: Abc, ABC, abc, 123
See Also:
getInputMode()

getInputMode

public String getInputMode()
Returns the currently selected input mode.

Returns:
the display name of the input mode by default the following modes are supported: Abc, ABC, abc, 123
See Also:
setInputMode(java.lang.String)

addInputMode

public static void addInputMode(String name,
                                Hashtable values,
                                boolean firstUpcase)
Adds a new input mode hashtable with the given name and set of values.

Parameters:
name - a unique display name for the input mode e.g. ABC, 123 etc...
values - The key for the hashtable is an Integer keyCode and the value is a String containing the characters to toggle between for the given keycode
firstUpcase - indicates if this input mode in an input mode used for the special case where the first letter is an upper case letter

getInputModeOrder

public String[] getInputModeOrder()
Returns the order in which input modes are toggled.

Returns:
the order in which input modes are toggled
See Also:
setInputModeOrder(java.lang.String[])

setInputModeOrder

public void setInputModeOrder(String[] order)
Sets the order in which input modes are toggled and allows disabling/hiding an input mode.

Parameters:
order - the order for the input modes in this field
See Also:
getInputModeOrder()

getDefaultInputModeOrder

public static String[] getDefaultInputModeOrder()
Returns the order in which input modes are toggled by default.

Returns:
the default order for the input modes in this field
See Also:
setDefaultInputModeOrder(java.lang.String[])

setDefaultInputModeOrder

public static void setDefaultInputModeOrder(String[] order)
Sets the order in which input modes are toggled by default and allows disabling/hiding an input mode.

Parameters:
order - the order for the input modes in all future created fields
See Also:
getDefaultInputModeOrder()

setCursorPosition

public void setCursorPosition(int pos)
Set the position of the cursor.

Parameters:
pos - the position of the cursor
See Also:
getCursorPosition()

getCursorPosition

public int getCursorPosition()
Returns the position of the cursor.

Returns:
the position of the cursor
See Also:
setCursorPosition(int)

setText

public void setText(String text)
Description copied from class: TextArea
Sets the text within this text area.

Overrides:
setText in class TextArea
Parameters:
text - new value for the text area
See Also:
TextArea.getText()

isQwertyInput

public boolean isQwertyInput()
True is this is a qwerty device or a device that is currently in qwerty mode.

Returns:
currently defaults to false

setQwertyInput

public void setQwertyInput(boolean qwerty)
Set this device to operate in or no longer operate in qwerty mode.

Parameters:
qwerty - indicate whether device should be set to qwerty mode or not

keyReleased

public void keyReleased(int keyCode)
Description copied from class: Component
If this Component is focused, the key released event will call this method.

Overrides:
keyReleased in class TextArea
Parameters:
keyCode - the key code value to indicate a physical key.

getSymbolTable

public static char[] getSymbolTable()
Returns the symbol table for the device.

Returns:
symbol table of the device
See Also:
setSymbolTable(char[])

setSymbolTable

public static void setSymbolTable(char[] table)
Sets the symbol table to show when the user clicks the symbol table key.

Parameters:
table - the symbol table
See Also:
getSymbolTable()

setEditable

public void setEditable(boolean b)
Description copied from class: TextArea
Sets this text area to be editable or readonly.

Overrides:
setEditable in class TextArea
Parameters:
b - true is text are is editable; otherwise false

keyPressed

public void keyPressed(int keyCode)
Description copied from class: Component
If this Component is focused, the key pressed event will call this method.

Overrides:
keyPressed in class TextArea
Parameters:
keyCode - the key code value to indicate a physical key.

paint

public void paint(Graphics g)
Description copied from class: Component
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

Specified by:
paint in interface Animation
Overrides:
paint in class TextArea
Parameters:
g - the component graphics

setCursorBlinkTimeOn

public void setCursorBlinkTimeOn(int time)
The amount of time in milliseconds in which the cursor is visible.

Parameters:
time - time in milliseconds in which the cursor is visible
See Also:
getCursorBlinkTimeOn()

setCursorBlinkTimeOff

public void setCursorBlinkTimeOff(int time)
The amount of time in milliseconds in which the cursor is invisible.

Parameters:
time - time in milliseconds in which the cursor is invisible
See Also:
getCursorBlinkTimeOff()

getCursorBlinkTimeOn

public int getCursorBlinkTimeOn()
The amount of time in milliseconds in which the cursor is visible.

Returns:
time in milliseconds in which the cursor is visible
See Also:
setCursorBlinkTimeOn(int)

getCursorBlinkTimeOff

public int getCursorBlinkTimeOff()
The amount of time in milliseconds in which the cursor is invisible.

Returns:
time in milliseconds in which the cursor is invisible
See Also:
setCursorBlinkTimeOff(int)

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame.

Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary

pointerReleased

public void pointerReleased(int x,
                            int y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method.

Overrides:
pointerReleased in class TextArea
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

isUseSoftkeys

public boolean isUseSoftkeys()
When set to true softkeys are used to enable delete functionality.

Returns:
true if softkeys are used to enable delete functionality

setUseSoftkeys

public void setUseSoftkeys(boolean useSoftkeys)
When set to true softkeys are used to enable delete functionality.

Parameters:
useSoftkeys - value indicating whether softkeys are used to enable delete functionality

addDataChangeListener

public void addDataChangeListener(DataChangedListener d)
Adds a listener for data change events it will be invoked for every change made to the text field.

Parameters:
d - the DataChangedListener
See Also:
removeDataChangeListener(com.sun.dtv.lwuit.events.DataChangedListener)

removeDataChangeListener

public void removeDataChangeListener(DataChangedListener d)
Removes the listener for data change events.

Parameters:
d - the DataChangedListener
See Also:
addDataChangeListener(com.sun.dtv.lwuit.events.DataChangedListener)

isReplaceMenu

public boolean isReplaceMenu()
Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.

Returns:
true if the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field

setReplaceMenu

public void setReplaceMenu(boolean replaceMenu)
Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.

Parameters:
replaceMenu - true if the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field

isReplaceMenuDefault

public static boolean isReplaceMenuDefault()
Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.

Returns:
default value for isReplaceMenu() return value
See Also:
isReplaceMenu(), setReplaceMenuDefault(boolean)

setReplaceMenuDefault

public static void setReplaceMenuDefault(boolean replaceMenu)
Indicates whether the menu of the form should be replaced with the T9/Clear commands for the duration of interactivity with the text field.

Parameters:
replaceMenu - default value for isReplaceMenu() return value
See Also:
isReplaceMenu(), isReplaceMenuDefault()

setQwertyAutoDetect

public static void setQwertyAutoDetect(boolean v)
Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly.

Parameters:
v - value indicating whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly

setQwertyDevice

public static void setQwertyDevice(boolean v)
The default value for the qwerty flag so it doesn't need setting for every text field individually.

Parameters:
v - default value for the qwerty flag so it doesn't need setting for every text field individually

isQwertyAutoDetect

public static boolean isQwertyAutoDetect()
Indicates whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly.

Returns:
value indicating whether the text field should try to auto detect qwerty and switch the qwerty device flag implicitly

isQwertyDevice

public static boolean isQwertyDevice()
The default value for the qwerty flag so it doesn't need setting for every text field individually.

Returns:
default value for the qwerty flag so it doesn't need setting for every text field individually.

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.