|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.j4me.ui.components.Component
org.j4me.ui.components.TextBox
public class TextBox
A TextBox
is a component for entering text, numbers, and keyboard data.
It equivalent to the javax.microedition.lcdui.TextField
class.
This component is not yet complete. Features that still need to be added include:
TextField
Field Summary |
---|
Fields inherited from class org.j4me.ui.components.Component |
---|
container, HIGHLIGHTED_BORDER_WIDTH |
Constructor Summary | |
---|---|
TextBox()
Creates a new TextBox component. |
Method Summary | |
---|---|
boolean |
acceptsInput()
Tells if this component accepts user input or not. |
java.lang.String |
getLabel()
|
int |
getMaxSize()
Returns the maximum size (number of characters) that can be stored in this TextBox . |
protected int[] |
getPreferredComponentSize(Theme theme,
int viewportWidth,
int viewportHeight)
Returns the dimensions of the text box. |
java.lang.String |
getString()
Gets the contents of the TextBox as a string value. |
protected void |
hideNotify()
An event raised whenever the component is removed from the screen. |
boolean |
isPassword()
Returns if this text box is for sensitive data or not. |
boolean |
isPhoneNumber()
|
void |
keyPressed(int keyCode)
Called when a key is pressed. |
protected void |
paintComponent(javax.microedition.lcdui.Graphics g,
Theme theme,
int width,
int height,
boolean selected)
Paints the text box. |
void |
pointerPressed(int x,
int y)
Called when the pointer is pressed. |
protected void |
select()
Called when the text box's value is being edited. |
void |
setForAnyText()
Allows any text to be entered including letters, numbers, punctuation, and newlines. |
void |
setForNumericOnly()
Allows only integer values to be input. |
void |
setForPhoneNumber()
Allows for entering a phone number. |
void |
setLabel(java.lang.String label)
|
void |
setMaxSize(int maxSize)
Sets the maximum size (number of characters) that can be contained in this TextBox . |
void |
setPassword(boolean password)
Sets if this text box is for sensitive data or not. |
void |
setString(java.lang.String text)
Sets the contents of the TextBox as a string value, replacing
the previous contents. |
protected void |
showNotify()
An event raised whenever the component is made visible on the screen. |
int |
size()
Gets the number of characters that are currently stored in this TextBox . |
Methods inherited from class org.j4me.ui.components.Component |
---|
getHeight, getHorizontalAlignment, getPreferredSize, getScreen, getWidth, getX, getY, invalidate, isShown, keyReleased, keyRepeated, paint, paintRect, pointerDragged, pointerReleased, repaint, setHorizontalAlignment, visible |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TextBox()
TextBox
component.
Method Detail |
---|
public java.lang.String getLabel()
null
there is no text.public void setLabel(java.lang.String label)
label
- is the text that appears above the text box.
If null
there will be no text.public java.lang.String getString()
TextBox
as a string value.
null
if there is no data.setString(String)
public void setString(java.lang.String text)
TextBox
as a string value, replacing
the previous contents.
text
- is the new value of the TextBox
, or null if
the TextBox
is to be made empty.
- Throws:
java.lang.IllegalArgumentException
- if text
is illegal for the
current input constraints.
java.lang.IllegalArgumentException
- if text
would exceed the current
maximum capacity.- See Also:
getString()
public void setForAnyText()
public void setForNumericOnly()
public void setForPhoneNumber()
public boolean isPhoneNumber()
true
if this text box is for entering a phone number;
false
otherwise.public void setPassword(boolean password)
*
' characters.
The default is for non-sensitive data.
password
- is true
if this text box contains a password;
false
otherwise.public boolean isPassword()
The default is for non-sensitive data.
true
if this text box contains a password; false
otherwise.public int getMaxSize()
TextBox
.
setMaxSize(int)
public void setMaxSize(int maxSize)
TextBox
. If the current contents of the TextBox
are
larger than maxSize
, the contents are truncated to fit.
maxSize
- is the new maximum size. It must be 1 or more.public int size()
TextBox
.
TextBox
.protected void paintComponent(javax.microedition.lcdui.Graphics g, Theme theme, int width, int height, boolean selected)
paintComponent
in class Component
g
- is the Graphics
object to be used for rendering the item.theme
- is the application's theme. Use it to get fonts and colors.width
- is the width, in pixels, to paint the component.height
- is the height, in pixels, to paint the component.selected
- is true
when this components is currently selected
and false
when it is not.Component.paintComponent(Graphics, Theme, int, int, boolean)
protected int[] getPreferredComponentSize(Theme theme, int viewportWidth, int viewportHeight)
getPreferredComponentSize
in class Component
theme
- is the application's Theme
.viewportWidth
- is the width of the viewable area, in pixels,
the component can use.viewportHeight
- is the height of the viewable area, in pixels,
the component can use.
Component.getPreferredComponentSize(org.j4me.ui.Theme, int, int)
protected void showNotify()
paintComponent
method.
showNotify
in class Component
Component.showNotify()
protected void hideNotify()
hideNotify
in class Component
Component.hideNotify()
public boolean acceptsInput()
Component
The default implementation returns false
. Override this method
to return true
if the component accepts input.
acceptsInput
in class Component
true
because this component accepts user input.public void keyPressed(int keyCode)
keyPressed
in class Component
keyCode
- is the key code of the key that was pressed.public void pointerPressed(int x, int y)
pointerPressed
in class Component
x
- is the horizontal location where the pointer was pressed
relative to the top-left corner of the component.y
- is the vertical location where the pointer was pressed
relative to the top-left corner of the component.protected void select()
TextBox
screen.
When the user enters a new value the original screen returns and
is updated with the new value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |