|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Item
javax.microedition.lcdui.CustomItem
de.enough.polish.ui.FakeCustomItem
de.enough.polish.ui.FakeStringCustomItem
de.enough.polish.ui.FakeTextFieldCustomItem
public class FakeTextFieldCustomItem
Meant for classes that want to be compatible with javax.microedition.lcdui.CustomItem for IDEs only while extending de.enough.polish.ui.StringItem in reality.
Subclasses can change the hierarchy with preprocessing like this:
public class MyCustomItem
//#if polish.LibraryBuild
extends FakeStringCustomItem
//#else
//# extends StringItem
//#endif
This allows subclasses to access all fields and methods of the J2ME Polish item class.
Note that this class can never be used in reality. Ever.
| Field Summary | |
|---|---|
static int |
ANY
The user is allowed to enter any text. |
protected char |
caretChar
|
protected static javax.microedition.lcdui.Command |
CLEAR_CMD
|
static int |
CONSTRAINT_MASK
The mask value for determining the constraint mode. |
static int |
DECIMAL
The user is allowed to enter numeric values with optional decimal fractions, for example "-123", "0.123", or ".5". |
protected static javax.microedition.lcdui.Command |
DELETE_CMD
|
static int |
EMAILADDR
The user is allowed to enter an e-mail address. |
protected char |
emailSeparatorChar
|
protected boolean |
flashCaret
|
static int |
INITIAL_CAPS_SENTENCE
This flag is a hint to the implementation that during text editing, the initial letter of each sentence should be capitalized. |
static int |
INITIAL_CAPS_WORD
This flag is a hint to the implementation that during text editing, the initial letter of each word should be capitalized. |
protected boolean |
isUneditable
|
protected java.lang.Object |
lock
|
static int |
NON_PREDICTIVE
Indicates that the text entered does not consist of words that are likely to be found in dictionaries typically used by predictive input schemes. |
static int |
NUMERIC
The user is allowed to enter only an integer value. |
static int |
PASSWORD
Indicates that the text entered is confidential data that should be obscured whenever possible. |
static int |
PHONENUMBER
The user is allowed to enter a phone number. |
static int |
SENSITIVE
Indicates that the text entered is sensitive data that the implementation must never store into a dictionary or table for use in predictive, auto-completing, or other accelerated input schemes. |
protected boolean |
showCaret
|
protected java.lang.String |
title
|
static int |
UNEDITABLE
Indicates that editing is currently disallowed. |
static int |
URL
The user is allowed to enter a URL. |
| Fields inherited from class de.enough.polish.ui.FakeStringCustomItem |
|---|
bitMapFont, bitMapFontViewer, clipText, font, text, textColor, textEffect, textHorizontalAdjustment, textLines, textVerticalAdjustment, useSingleLine, xOffset |
| Fields inherited from class javax.microedition.lcdui.CustomItem |
|---|
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL |
| Constructor Summary | |
|---|---|
FakeTextFieldCustomItem(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints)
Creates a new TextField object with the given label, initial
contents, maximum size in characters, and constraints. |
|
FakeTextFieldCustomItem(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
Style style)
Creates a new TextField object with the given label, initial
contents, maximum size in characters, and constraints. |
|
| Method Summary | |
|---|---|
boolean |
animate()
Animates this item. |
void |
commandAction(javax.microedition.lcdui.Command cmd,
javax.microedition.lcdui.Displayable box)
|
void |
commandAction(javax.microedition.lcdui.Command cmd,
Item item)
Called by the system to indicate that a command has been invoked on a particular item. |
protected java.lang.String |
createCssSelector()
Retrieves the CSS selector for this item. |
protected void |
defocus(Style originalStyle)
Removes the focus from this item. |
void |
delete(int offset,
int length)
Deletes characters from the TextField. |
void |
fieldChanged(Field field,
int context)
|
protected Style |
focus(Style focStyle,
int direction)
Focuses this item. |
int |
getCaretPosition()
Gets the current input position. |
int |
getChars(char[] data)
Copies the contents of the TextField into a character array starting at index zero. |
int |
getConstraints()
Gets the current input constraints of the TextField. |
java.lang.String |
getDotSeparatedDecimalString()
Retrieves the decimal value entered with a dot as the decimal mark. |
int |
getMaxSize()
Returns the maximum size (number of characters) that can be stored in this TextField. |
java.lang.String |
getString()
Gets the contents of the TextField as a string value. |
protected boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the key-pressed event. |
protected boolean |
handleKeyReleased(int keyCode,
int gameAction)
Handles the key-released event. |
protected boolean |
handleKeyRepeated(int keyCode,
int gameAction)
Handles the key-repeated event. |
protected boolean |
handlePointerPressed(int x,
int y)
Handles the event when a pointer has been pressed at the specified position. |
protected void |
initContent(int firstLineWidth,
int lineWidth)
Initialises this item. |
void |
insert(char[] data,
int offset,
int length,
int position)
Inserts a subrange of an array of characters into the contents of the TextField. |
void |
insert(java.lang.String src,
int position)
Inserts a string into the contents of the TextField. |
protected void |
insertCharacter()
|
void |
paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
Paints the content of this item. |
void |
setCaretPosition(int position)
Sets the caret position. |
void |
setChars(char[] data,
int offset,
int length)
Sets the contents of the TextField from a character array,
replacing the previous contents. |
void |
setConstraints(int constraints)
Sets the input constraints of the TextField. |
void |
setInitialInputMode(java.lang.String characterSubset)
Sets a hint to the implementation as to the input mode that should be used when the user initiates editing of this TextField. |
void |
setInputMode(int inputMode)
Sets the input mode for this TextField. |
void |
setItemCommandListener(ItemCommandListener l)
Sets a listener for Commands to this Item,
replacing any previous
ItemCommandListener. |
int |
setMaxSize(int maxSize)
Sets the maximum size (number of characters) that can be contained in this TextField. |
void |
setString(java.lang.String text)
Sets the contents of the TextField as a string
value, replacing the previous contents. |
void |
setStyle(Style style)
Sets the style of this item. |
int |
size()
Gets the number of characters that are currently stored in this TextField. |
| Methods inherited from class de.enough.polish.ui.FakeStringCustomItem |
|---|
getFont, getText, hideNotify, releaseResources, setFont, setText, setText, showNotify, toString |
| Methods inherited from class javax.microedition.lcdui.CustomItem |
|---|
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int ANY
Constant 0 is assigned to ANY.
public static final int EMAILADDR
Constant 1 is assigned to EMAILADDR.
public static final int NUMERIC
Integer.parseInt(String).
The minus sign consumes space in the text object. It is thus
impossible to enter negative numbers into a text object whose maximum
size is 1.
Constant 2 is assigned to NUMERIC.
public static final int PHONENUMBER
The exact set of characters allowed is specific to the device and to the device's network and may include non-numeric characters, such as a "+" prefix character.
Some platforms may provide the capability to initiate voice calls
using the MIDlet.platformRequest method.
Constant 3 is assigned to PHONENUMBER.
public static final int URL
Constant 4 is assigned to URL.
public static final int DECIMAL
The implementation may display a period "." or a comma "," for the decimal fraction separator, depending on the conventions in use on the device. Similarly, the implementation may display other device-specific characters as part of a decimal string, such as spaces or commas for digit separators. However, the only characters allowed in the actual contents of the text object are period ".", minus sign "-", and the decimal digits.
The actual contents of a DECIMAL text object may be
empty. If the actual contents are not empty, they must conform to a
subset of the syntax for a FloatingPointLiteral as defined
by the Java Language Specification, section 3.10.2. This
subset syntax is defined as follows: the actual contents
must consist of an optional minus sign
"-", followed by one or more whole-number decimal digits,
followed by an optional fraction separator, followed by zero or more
decimal fraction digits. The whole-number decimal digits may be
omitted if the fraction separator and one or more decimal fraction
digits are present.
The syntax defined above is also enforced whenever the application attempts to set or modify the contents of the text object by calling a constructor or a method.
Parsing this string value into a numeric value suitable for
computation is the responsibility of the application. If the contents
are not empty, the result can be parsed successfully by
Double.valueOf and related methods if they are present
in the runtime environment.
The sign and the fraction separator consume space in the text object. Applications should account for this when assigning a maximum size for the text object.
Constant 5 is assigned to DECIMAL.
public static final int PASSWORD
*" character. The
PASSWORD modifier is useful for entering
confidential information
such as passwords or personal identification numbers (PINs).
Data entered into a PASSWORD field is treated
similarly to SENSITIVE
in that the implementation must never store the contents into a
dictionary or table for use in predictive, auto-completing, or other
accelerated input schemes. If the PASSWORD bit is
set in a constraint
value, the SENSITIVE and
NON_PREDICTIVE bits are also considered to be
set, regardless of their actual values. In addition, the
INITIAL_CAPS_WORD and
INITIAL_CAPS_SENTENCE flag bits should be ignored
even if they are set.
The PASSWORD modifier can be combined with
other input constraints
by using the bit-wise OR operator (|).
The PASSWORD modifier is not
useful with some constraint values such as
EMAILADDR, PHONENUMBER,
and URL. These combinations are legal, however,
and no exception is
thrown if such a constraint is specified.
Constant 0x10000 is assigned to
PASSWORD.
public static final int UNEDITABLE
The UNEDITABLE modifier can be combined with
other input constraints
by using the bit-wise OR operator (|).
Constant 0x20000 is assigned to UNEDITABLE.
public static final int SENSITIVE
The SENSITIVE modifier can be combined with other input
constraints by using the bit-wise OR operator
(|).
Constant 0x40000 is assigned to
SENSITIVE.
public static final int NON_PREDICTIVE
The NON_PREDICTIVE modifier can be combined
with other input
constraints by using the bit-wise OR operator
(|).
Constant 0x80000 is assigned to
NON_PREDICTIVE.
public static final int INITIAL_CAPS_WORD
If the application specifies both the
INITIAL_CAPS_WORD and the
INITIAL_CAPS_SENTENCE flags,
INITIAL_CAPS_WORD behavior should be used.
The INITIAL_CAPS_WORD modifier can be combined
with other input
constraints by using the bit-wise OR operator
(|).
Constant 0x100000 is assigned to
INITIAL_CAPS_WORD.
public static final int INITIAL_CAPS_SENTENCE
If the application specifies both the
INITIAL_CAPS_WORD and the
INITIAL_CAPS_SENTENCE flags,
INITIAL_CAPS_WORD behavior should be used.
The INITIAL_CAPS_SENTENCE modifier can be
combined with other input
constraints by using the bit-wise OR operator
(|).
Constant 0x200000 is assigned to
INITIAL_CAPS_SENTENCE.
public static final int CONSTRAINT_MASK
AND operation with a value returned by
getConstraints() and
CONSTRAINT_MASK in order to retrieve the current
constraint mode,
in order to remove any modifier flags such as the
PASSWORD flag.
Constant 0xFFFF is assigned to
CONSTRAINT_MASK.
protected static javax.microedition.lcdui.Command DELETE_CMD
protected static javax.microedition.lcdui.Command CLEAR_CMD
protected char caretChar
protected boolean showCaret
protected java.lang.String title
protected char emailSeparatorChar
protected final java.lang.Object lock
protected boolean flashCaret
protected boolean isUneditable
| Constructor Detail |
|---|
public FakeTextFieldCustomItem(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints)
TextField object with the given label, initial
contents, maximum size in characters, and constraints.
If the text parameter is null, the
TextField is created empty.
The maxSize parameter must be greater than zero.
An IllegalArgumentException is thrown if the
length of the initial contents string exceeds maxSize.
However,
the implementation may assign a maximum size smaller than the
application had requested. If this occurs, and if the length of the
contents exceeds the newly assigned maximum size, the contents are
truncated from the end in order to fit, and no exception is thrown.
label - item labeltext - the initial contents, or null if the TextField is to be emptymaxSize - the maximum capacity in charactersconstraints - see input constraints
java.lang.IllegalArgumentException - if maxSize is zero or less
or if the value of the constraints parameter is invalid
or if text is illegal for the specified constraints
or if the length of the string exceeds the requested maximum capacity
public FakeTextFieldCustomItem(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
Style style)
TextField object with the given label, initial
contents, maximum size in characters, and constraints.
If the text parameter is null, the
TextField is created empty.
The maxSize parameter must be greater than zero.
An IllegalArgumentException is thrown if the
length of the initial contents string exceeds maxSize.
However,
the implementation may assign a maximum size smaller than the
application had requested. If this occurs, and if the length of the
contents exceeds the newly assigned maximum size, the contents are
truncated from the end in order to fit, and no exception is thrown.
label - item labeltext - the initial contents, or null if the TextField is to be emptymaxSize - the maximum capacity in charactersconstraints - see input constraintsstyle - the CSS style for this field
java.lang.IllegalArgumentException - if maxSize is zero or less
or if the value of the constraints parameter is invalid
or if text is illegal for the specified constraints
or if the length of the string exceeds the requested maximum capacity| Method Detail |
|---|
public java.lang.String getString()
TextField as a string value.
setString(java.lang.String)public java.lang.String getDotSeparatedDecimalString()
java.lang.IllegalStateException - when the TextField is not DECIMAL constrainedpublic void setString(java.lang.String text)
TextField as a string
value, replacing the previous contents.
text - the new value of the TextField, or null if the TextField is to be made empty
java.lang.IllegalArgumentException - if text is illegal for the current input constraints
or if the text would exceed the current maximum capacitygetString()public int getChars(char[] data)
TextField into a character array starting at index zero.
Array elements beyond the characters copied are left
unchanged.
data - the character array to receive the value
java.lang.ArrayIndexOutOfBoundsException - if the array is too short for the contents
java.lang.NullPointerException - if data is nullsetChars(char[], int, int)
public void setChars(char[] data,
int offset,
int length)
TextField from a character array,
replacing the previous contents.
Characters are copied from the region of the
data array
starting at array index offset and running for
length characters.
If the data array is null, the TextField
is set to be empty and the other parameters are ignored.
The offset and length parameters must
specify a valid range of characters within
the character array data.
The offset parameter must be within the
range [0..(data.length)], inclusive.
The length parameter
must be a non-negative integer such that
(offset + length) <= data.length.
data - the source of the character dataoffset - the beginning of the region of characters to copylength - the number of characters to copy
java.lang.ArrayIndexOutOfBoundsException - - if offset and length do not specify a valid range within the data array
java.lang.IllegalArgumentException - - if data is illegal for the current input constraints
or if the text would exceed the current maximum capacitygetChars(char[])
public void insert(java.lang.String src,
int position)
TextField. The string is
inserted just prior to the character indicated by the
position parameter, where zero specifies the first
character of the contents of the TextField. If
position is
less than or equal to zero, the insertion occurs at the beginning of
the contents, thus effecting a prepend operation. If
position is greater than or equal to the current size of
the contents, the insertion occurs immediately after the end of the
contents, thus effecting an append operation. For example,
text.insert(s, text.size()) always appends the string
s to the current contents.
The current size of the contents is increased by the number of inserted characters. The resulting string must fit within the current maximum capacity.
If the application needs to simulate typing of characters it can
determining the location of the current insertion point
("caret")
using the with getCaretPosition() method.
For example,
text.insert(s, text.getCaretPosition()) inserts the string
s at the current caret position.
src - the String to be insertedposition - the position at which insertion is to occur
java.lang.IllegalArgumentException - if the resulting contents would be illegal for the current input constraints
or if the insertion would exceed the current maximum capacity
java.lang.NullPointerException - if src is null
public void insert(char[] data,
int offset,
int length,
int position)
TextField. The offset and
length parameters indicate the subrange
of the data array to be used for insertion. Behavior is otherwise
identical to insert(String, int).
The offset and length parameters must
specify a valid range of characters within
the character array data.
The offset parameter must be within the
range [0..(data.length)], inclusive.
The length parameter
must be a non-negative integer such that
(offset + length) <= data.length.
data - - the source of the character dataoffset - - the beginning of the region of characters to copylength - - the number of characters to copyposition - - the position at which insertion is to occur
java.lang.ArrayIndexOutOfBoundsException - - if offset and length do not specify a valid range within the data array
java.lang.IllegalArgumentException - - if the resulting contents would be illegal for the current input constraints
or if the insertion would exceed the current maximum capacity
java.lang.NullPointerException - - if data is null
public void delete(int offset,
int length)
TextField.
The offset and length parameters must
specify a valid range of characters within
the contents of the TextField.
The offset parameter must be within the
range [0..(size())], inclusive.
The length parameter
must be a non-negative integer such that
(offset + length) <= size().
offset - the beginning of the region to be deletedlength - the number of characters to be deleted
java.lang.IllegalArgumentException - if the resulting contents would be illegal for the current input constraints
java.lang.StringIndexOutOfBoundsException - if offset and length do not specify a valid range within the contents of the TextFieldpublic int getMaxSize()
TextField.
setMaxSize(int)public int setMaxSize(int maxSize)
TextField. If the current contents of the
TextField are larger than
maxSize, the contents are truncated to fit.
maxSize - the new maximum size
java.lang.IllegalArgumentException - if maxSize is zero or less.
or if the contents after truncation would be illegal for the current input constraintsgetMaxSize()public int size()
TextField.
public int getCaretPosition()
public void setCaretPosition(int position)
position - the new caret position, 0 puts the caret at the start of the line, getString().length moves the caret to the end of the input.public void setConstraints(int constraints)
TextField. If
the the current contents
of the TextField do not match the new
constraints, the contents are
set to empty.
constraints - see input constraints
java.lang.IllegalArgumentException - if constraints is not any of the ones specified in input constraintsgetConstraints()public int getConstraints()
TextField.
setConstraints(int)public void setInitialInputMode(java.lang.String characterSubset)
TextField. The
characterSubset parameter names a subset of Unicode
characters that is used by the implementation to choose an initial
input mode. If null is passed, the implementation should
choose a default input mode.
When the direct input mode is used, J2ME Polish will ignore this call completely.
characterSubset - a string naming a Unicode character subset, or null
public void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
FakeCustomItem
paintContent in class FakeStringCustomItemx - the left start positiony - the upper start positionleftBorder - the left border, nothing must be painted left of this positionrightBorder - the right border, nothing must be painted right of this positiong - the Graphics on which this item should be painted.
protected void initContent(int firstLineWidth,
int lineWidth)
FakeCustomItem
initContent in class FakeStringCustomItemfirstLineWidth - the maximum width of the first linelineWidth - the maximum width of any following linesFakeCustomItem.contentWidth,
FakeCustomItem.contentHeight,
FakeCustomItem.preferredWidth,
FakeCustomItem.preferredHeightprotected java.lang.String createCssSelector()
FakeCustomItem
createCssSelector in class FakeStringCustomItempublic void setStyle(Style style)
FakeCustomItem
setStyle in class FakeStringCustomItemstyle - the new style for this item.protected void insertCharacter()
public boolean animate()
FakeCustomItem
animate in class FakeStringCustomItem
protected boolean handleKeyPressed(int keyCode,
int gameAction)
FakeCustomItem
handleKeyPressed in class FakeCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
protected boolean handleKeyRepeated(int keyCode,
int gameAction)
FakeCustomItem
handleKeyRepeated in class FakeCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
FakeCustomItem.handleKeyPressed(int, int)
protected boolean handleKeyReleased(int keyCode,
int gameAction)
FakeCustomItem
handleKeyReleased in class FakeCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
FakeCustomItem.handleKeyPressed(int, int)
protected boolean handlePointerPressed(int x,
int y)
handlePointerPressed in class FakeCustomItemx - the x position of the pointer pressingy - the y position of the pointer pressing
this method is used for determining whether the event belongs to this item,
for a helper method for determining whether the event took place into the actual content area,
FakeCustomItem.handleKeyPressed(int, int),
for calculating the horizontal position relative to the content (relX - contentX),
for calculating the vertical position relative to the content (relY - contentY)
public void commandAction(javax.microedition.lcdui.Command cmd,
javax.microedition.lcdui.Displayable box)
commandAction in interface javax.microedition.lcdui.CommandListenerpublic void setItemCommandListener(ItemCommandListener l)
FakeCustomItemCommands to this Item,
replacing any previous
ItemCommandListener. A null reference
is allowed and has the effect of removing any existing listener.
When no listener is registered, J2ME Polish notifies the
command-listener of the current screen, when an item command
has been selected.
It is illegal to call this method if this Item
is contained within an Alert.
setItemCommandListener in class FakeCustomIteml - the new listener, or null.
public void commandAction(javax.microedition.lcdui.Command cmd,
Item item)
ItemCommandListener
commandAction in interface ItemCommandListenercmd - the Command that was invokeditem - the Item on which the command was invokedprotected void defocus(Style originalStyle)
FakeCustomItem
defocus in class FakeStringCustomItemoriginalStyle - the original style which will be restored.
protected Style focus(Style focStyle,
int direction)
FakeCustomItem
focus in class FakeCustomItemfocStyle - the style which is used to indicate the focused statedirection - the direction from which this item is focused,
either Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.RIGHT or 0.
When 0 is given, the direction is unknown.
public void fieldChanged(Field field,
int context)
public void setInputMode(int inputMode)
inputMode - the input mode
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||