public class TextArea extends Component implements ActionSource, TextHolder
An optionally multi-line editable region that can display text and allow a user to edit it.
By default the text area will grow based on its content.
TextArea
is useful both for text input and for displaying multi-line data, it is used internally
by components such as SpanLabel
&
SpanButton
.
TextArea
& TextField
are very similar, we discuss the main differences
between the two here
. In fact they are so similar that our sample code
below was written for TextField
but should be interchangeable with TextArea
.
Modifier and Type | Field and Description |
---|---|
static int |
ANY
Allows any type of input into a text field, if a constraint is not supported
by an underlying implementation this will be the default.
|
static int |
DECIMAL
The user is allowed to enter numeric values with optional decimal
fractions, for example "-123", "0.123", or ".5".
|
static int |
EMAILADDR
The user is allowed to enter an e-mail address.
|
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.
|
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.
|
static int |
UNEDITABLE
Indicates that editing is currently disallowed.
|
static int |
UPPERCASE
This flag is a hint to the implementation that the text in this
field should be upper case
|
static int |
URL
The user is allowed to enter a URL.
|
static int |
USERNAME
This flag is a hint to the implementation that this field contains
a username.
|
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, CROSSHAIR_CURSOR, DEFAULT_CURSOR, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, E_RESIZE_CURSOR, HAND_CURSOR, LEFT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NW_RESIZE_CURSOR, RIGHT, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, TOP, W_RESIZE_CURSOR, WAIT_CURSOR
Constructor and Description |
---|
TextArea()
Creates an empty text area, this constructor
will create a single line text area similar to a text field!
|
TextArea(int rows,
int columns)
Creates an area with the given rows and columns
|
TextArea(int rows,
int columns,
int constraint)
Creates an area with the given rows, columns and constraint
|
TextArea(String text)
Creates an area with the given text, this constructor
will create a single line text area similar to a text field!
|
TextArea(String text,
int maxSize)
Creates an area with the given text and maximum size, this constructor
will create a single line text area similar to a text field!
|
TextArea(String text,
int rows,
int columns)
Creates an area with the given text, rows and columns
|
TextArea(String text,
int rows,
int columns,
int constraint)
Creates an area with the given text, rows, columns and constraint
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener a)
Add an action listener which is invoked when the text area was modified not during
modification.
|
void |
addCloseListener(ActionListener l)
Adds a listener to be called with this TextArea is "closed".
|
void |
addDataChangedListener(DataChangedListener d)
Adds a listener for data change events it will be invoked for every change
made to the text field, notice most platforms will invoke only the
DataChangedListener.CHANGED event
|
void |
addDataChangeListener(DataChangedListener d)
Deprecated.
use #addDataChangedListener(DataChangedListener) instead
|
static void |
autoDetectWidestChar(String s)
Searches the given string for the widest character using char width, this operation should only
be performed once and it solves cases where a devices language might have a char bigger than 'W'
that isn't consistently bigger.
|
void |
bindProperty(String prop,
BindTarget target)
Binds the given property name to the given bind target
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
protected Dimension |
calcScrollSize()
Method that can be overriden to represent the actual size of the component
when it differs from the desireable size for the viewport
|
protected TextSelection.Spans |
calculateTextSelectionSpan(TextSelection sel)
Calculates the spans for the the given text selection.
|
protected void |
deinitialize()
Invoked to indicate that the component initialization is being reversed
since the component was detached from the container hierarchy.
|
protected void |
fireClicked()
When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method
in order to allow 3 button devices to work properly.
|
void |
fireDataChanged(int type,
int index)
Alert the TextField listeners the text has been changed on the TextField
|
void |
fireDoneEvent()
Fire the done event to done listener
|
int |
getAbsoluteAlignment()
Deprecated.
this method is redundant and no longer used
|
int |
getActualRows()
Returns the number of actual rows in the text area taking into consideration
growsByContent
|
int |
getAlignment()
Deprecated.
use Style.getAlignment instead
|
double |
getAsDouble(double invalid)
Convenience method for numeric text fields, returns the value as a number or invalid if the value in the
text field isn't a number
|
int |
getAsInt(int invalid)
Convenience method for numeric text fields, returns the value as a number or invalid if the value in the
text field isn't a number
|
long |
getAsLong(long invalid)
Convenience method for numeric text fields, returns the value as a number or invalid if the value in the
text field isn't a number
|
String[] |
getBindablePropertyNames()
Returns the names of the properties within this component that can be bound for persistence,
the order of these names mean that the first one will be the first bound
|
Class[] |
getBindablePropertyTypes()
Returns the types of the properties that are bindable within this component
|
Object |
getBoundPropertyValue(String prop)
Allows the binding code to extract the value of the property
|
int |
getColumns()
Returns the number of columns in the text area
|
int |
getConstraint()
Returns the editing constraint value
|
int |
getCursorPosition()
Returns the position of the cursor char position
|
int |
getCursorX()
Returns the position of the cursor char position in the current line.
|
int |
getCursorY()
Returns the position of the cursor line position
|
static int |
getDefaultValign()
Indicates the default vertical alignment for a text field, only applies to single line text fields
|
ActionListener |
getDoneListener()
Gets the done listener of this TextField.
|
int |
getGrowLimit()
Indicates the maximum number of rows in a text area after it has grown, -1 indicates no limit
|
String |
getHint()
Returns the hint text
|
Image |
getHintIcon()
Returns the hint icon
|
Label |
getHintLabel()
Returns the hint label component that can be customized directly
|
String |
getInputMode()
Returns the currently selected input mode
|
String[] |
getInputModeOrder()
Returns the order in which input modes are toggled
|
int |
getLines()
Returns the number of text lines in the TextArea
|
int |
getLinesToScroll()
Indicates the number of lines to scroll with every scroll operation
|
int |
getMaxSize()
Returns the maximum size for the text area
|
int |
getPreferredTabIndex()
Gets the preferred tab index of this component.
|
int |
getRows()
Returns the number of rows in the text area
|
int |
getRowsGap()
Gets the num of pixels gap between the rows
|
Style |
getStyle()
Returns the current Component Style allowing code to draw the current component, you
should normally use getUnselected/Pressed/DisabledStyle() and not this method since
it will return different values based on component state.
|
String |
getText()
Returns the text in the text area
|
String |
getTextAt(int line)
Returns the text in the given row of the text box
|
TextSelection.TextSelectionSupport |
getTextSelectionSupport()
Returns text selection support object for this component.
|
String |
getUnsupportedChars()
Unsupported characters is a string that contains characters that cause issues
when rendering on some problematic fonts.
|
int |
getVerticalAlignment()
Returns the vertical alignment of the text field, this only applies to single line text field
|
static char |
getWidestChar()
Indicates the widest character in the alphabet, this is useful for detecting
linebreaks internally.
|
protected void |
initComponent()
Allows subclasses to bind functionality that relies on fully initialized and
"ready for action" component state
|
protected void |
initLaf(UIManager uim)
This method initializes the Component defaults constants
|
boolean |
isActAsLabel()
This flag indicates that the text area should try to act as a label and try to fix more accurately within it's bounds
this might make it slower as a result
|
static boolean |
isAutoDegradeMaxSize()
Indicates whether a high value for default maxSize will be reduced to a lower
value if the underlying platform throws an exception.
|
boolean |
isEditable()
Returns true if this area is editable
|
boolean |
isEditing()
Indicates whether we are currently editing this text area
|
boolean |
isEnableInputScroll()
Indicates whether text field input should scroll to the right side when no
more room for the input is present.
|
boolean |
isEndsWith3Points()
If the TextArea text is too long to fit the text to the widget this will add "..."
at the last displayable row.
|
protected boolean |
isEnterKey(int keyCode)
Indicates the enter key to be used for editing the text area and by the
text field
|
boolean |
isGrowByContent()
Indicates that the text area should "grow" in height based on the content beyond the
limits indicate by the rows variable
|
boolean |
isPendingCommit()
Returns true if the text field is waiting for a commit on editing
|
boolean |
isQwertyInput()
True is this is a qwerty device or a device that is currently in
qwerty mode.
|
boolean |
isScrollableY()
Indicates whether the component should/could scroll on the Y axis
|
protected boolean |
isSelectableInteraction()
This method allows a component to indicate that it is interested in an "implicit" select
command to appear in the "fire" button when 3 softbuttons are defined in a device.
|
boolean |
isSingleLineTextArea()
Indicates whether this is a single line text area, in which case "growing" won't
work as expected.
|
boolean |
isTextSelectionEnabled()
Returns true if text selection is enabled on this label.
|
static boolean |
isUseStringWidth()
By default text area uses charWidth since its much faster on some devices
than string width.
|
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 |
pointerHover(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking
the display.
|
void |
pointerHoverReleased(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking
the display.
|
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event
will call this method
|
protected char[] |
preprocess(String text)
Override this to modify the text for rendering in cases of invalid characters
for display, this method allows the developer to replace such characters e.g.:
replace "\\t" with 4 spaces
|
void |
registerAsInputDevice()
Deprecated.
Don't call this method directly, unless you really know what you're doing. It is used
primarily by implementation APIs.
|
void |
removeActionListener(ActionListener a)
Removes an action listener
|
void |
removeCloseListener(ActionListener l)
Removes close listener.
|
void |
removeDataChangedListener(DataChangedListener d)
Removes the listener for data change events
|
void |
removeDataChangeListener(DataChangedListener d)
Deprecated.
use #removeDataChangedListener(DataChangedListener) instead
|
void |
setActAsLabel(boolean actAsLabel)
This flag indicates that the text area should try to act as a label and try to fix more accurately within it's bounds
this might make it slower as a result
|
void |
setAlignment(int align)
Deprecated.
use Style.setAlignment instead
|
static void |
setAutoDegradeMaxSize(boolean value)
Indicates whether a high value for default maxSize will be reduced to a lower
value if the underlying platform throws an exception.
|
void |
setBoundPropertyValue(String prop,
Object value)
Sets the value of a bound property within this component, notice that this method MUST NOT fire
the property change event when invoked to prevent recursion!
|
void |
setColumns(int columns)
Sets the number of columns in the text area
|
void |
setConstraint(int constraint)
Sets the constraint which provides a hint to the virtual keyboard input, notice this doesn't
limit input type in any way!
|
static void |
setDefaultMaxSize(int value)
Sets the default limit for the native text box size
|
static void |
setDefaultValign(int aDefaultValign)
Indicates the default vertical alignment for a text field, only applies to single line text fields
|
void |
setDoneListener(ActionListener l)
Sets a Done listener on the TextField - notice this listener will be called
only on supported platforms that supports done action on the keyboard
|
void |
setEditable(boolean b)
Sets this text area to be editable or readonly
|
void |
setEndsWith3Points(boolean endsWith3Points)
If the TextArea text is too long to fit the text to the widget this will add "..."
at the last displayable row.
|
void |
setGrowByContent(boolean growByContent)
Indicates that the text area should "grow" in height based on the content beyond the
limits indicate by the rows variable
|
void |
setGrowLimit(int growLimit)
Indicates the maximum number of rows in a text area after it has grown, -1 indicates no limit
|
void |
setHint(String hint)
Sets the TextArea hint text, the hint text is displayed on the TextArea
When there is no text in the TextArea
|
void |
setHint(String hint,
Image icon)
Sets the TextArea hint text and Icon, the hint text and icon are
displayed on the TextArea when there is no text in the TextArea
|
void |
setHintIcon(Image icon)
Sets the TextArea hint icon, the hint is displayed on the TextArea
When there is no text in the TextArea
|
void |
setLinesToScroll(int linesToScroll)
Indicates the number of lines to scroll with every scroll operation
|
void |
setMaxSize(int maxSize)
Sets the maximum size of the text area
|
void |
setRows(int rows)
Sets the number of rows in the text area
|
void |
setRowsGap(int rowsGap)
The gap in pixels between rows
|
void |
setSingleLineTextArea(boolean singleLineTextArea)
Indicates whether this is a single line text area, in which case "growing" won't
work as expected.
|
void |
setText(String t)
Sets the text within this text area
|
void |
setTextSelectionEnabled(boolean enabled)
Enables text selection on this TextArea.
|
void |
setUnsupportedChars(String unsupportedChars)
Unsupported characters is a string that contains characters that cause issues
when rendering on some problematic fonts.
|
static void |
setUseStringWidth(boolean aUseStringWidth)
By default text area uses charWidth since its much faster on some devices
than string width.
|
void |
setVerticalAlignment(int valign)
Sets the vertical alignment of the text field to one of: CENTER, TOP, BOTTOM
only applies to single line text field |
static void |
setWidestChar(char widestC)
Indicates the widest character in the alphabet, this is useful for detecting
linebreaks internally.
|
void |
setWidth(int width)
Sets the Component width, this method is exposed for the purpose of
external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used. |
protected boolean |
shouldRenderComponentSelection()
Special case for text components, if they are editing they should always render the selected state
A component can indicate whether it is interested in rendering it's selection explicitly, this defaults to
true in non-touch UI's and false in touch UI's except for the case where a user clicks the screen.
|
void |
startEditing()
Launches the text field editing, notice that calling this in a callSerially is generally considered good practice
|
void |
startEditingAsync()
Launches the text field editing in a callserially call
|
void |
stopEditing()
Stops text editing of this field if it is being edited
|
void |
stopEditing(Runnable onFinish)
Stops text editing of this field if it is being edited
|
void |
unbindProperty(String prop,
BindTarget target)
Removes a bind target from the given property name
|
addDragFinishedListener, addDragOverListener, addDropListener, addFocusListener, addLongPressListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, addStateChangeListener, animate, blocksSideSwipe, cancelRepaints, clearClientProperties, contains, containsOrOwns, createStyleAnimation, deinitializeCustomStyle, dragEnter, dragExit, dragFinished, draggingOver, dragInitiated, drawDraggedImage, drop, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getAllStyles, getAnimationManager, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getCursor, getDefaultDragTransparency, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getDragTransparency, getEditingDelegate, getGridPosX, getGridPosY, getHeight, getInlineAllStyles, getInlineDisabledStyles, getInlinePressedStyles, getInlineSelectedStyles, getInlineStylesTheme, getInlineUnselectedStyles, getInnerHeight, getInnerPreferredH, getInnerPreferredW, getInnerWidth, getInnerX, getInnerY, getLabelForComponent, getName, getNativeOverlay, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getOuterHeight, getOuterPreferredH, getOuterPreferredW, getOuterWidth, getOuterX, getOuterY, getOwner, getParent, getPreferredH, getPreferredSize, getPreferredSizeStr, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypeNames, getPropertyTypes, getPropertyValue, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getSideGap, getTabIndex, getTensileLength, getTooltip, getUIID, getUIManager, getUnselectedStyle, getVisibleBounds, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFixedPreferredSize, hasFocus, hideNativeOverlay, initCustomStyle, initDisabledStyle, initPressedStyle, initSelectedStyle, initUnselectedStyle, installDefaultPainter, isAlwaysTensile, isBlockLead, isCellRenderer, isChildOf, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isEnabled, isFlatten, isFocusable, isGrabsPointerEvents, isHidden, isHidden, isHideInLandscape, isHideInPortrait, isIgnorePointerEvents, isInClippingRegion, isInitialized, isOpaque, isOwnedBy, isPinchBlocksDragAndDrop, isRippleEffect, isRTL, isScrollable, isScrollableX, isScrollVisible, isSetCursorSupported, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isTraversable, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintBorderBackground, paintComponent, paintComponent, paintIntersectingComponentsAbove, paintLock, paintLockRelease, paintRippleOverlay, paintScrollbars, paintScrollbarX, paintScrollbarY, paintShadows, paramString, parsePreferredSize, pinch, pinch, pinchReleased, pointerDragged, pointerDragged, pointerHoverPressed, pointerPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, refreshTheme, refreshTheme, remove, removeDragFinishedListener, removeDragOverListener, removeDropListener, removeFocusListener, removeLongPressListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, removeStateChangeListener, repaint, repaint, requestFocus, resetFocusable, respondsToPointerEvents, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBlockLead, setCellRenderer, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setCursor, setDefaultDragTransparency, setDirtyRegion, setDisabledStyle, setDraggable, setDragTransparency, setDropTarget, setEditingDelegate, setEnabled, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHidden, setHidden, setHideInLandscape, setHideInPortrait, setIgnorePointerEvents, setInitialized, setInlineAllStyles, setInlineDisabledStyles, setInlinePressedStyles, setInlineSelectedStyles, setInlineStylesTheme, setInlineUnselectedStyles, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setOpaque, setOwner, setPinchBlocksDragAndDrop, setPreferredH, setPreferredSize, setPreferredSizeStr, setPreferredTabIndex, setPreferredW, setPressedStyle, setPropertyValue, setRippleEffect, setRTL, setSameHeight, setSameSize, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setSnapToGrid, setTabIndex, setTactileTouch, setTensileDragEnabled, setTensileLength, setTooltip, setTraversable, setUIID, setUIID, setUnselectedStyle, setVisible, setX, setY, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, showNativeOverlay, stripMarginAndPadding, styleChanged, toImage, toString, updateNativeOverlay, visibleBoundsContains
public static final int ANY
public static final int EMAILADDR
public static final int NUMERIC
public static final int PHONENUMBER
public static final int URL
public static final int DECIMAL
public static final int PASSWORD
public static final int UNEDITABLE
public static final int SENSITIVE
public static final int NON_PREDICTIVE
public static final int INITIAL_CAPS_WORD
public static final int INITIAL_CAPS_SENTENCE
public static final int USERNAME
public static final int UPPERCASE
public TextArea(int rows, int columns)
rows
- the number of rowscolumns
- - the number of columnsIllegalArgumentException
- if rows <= 0 or columns <= 1public TextArea(int rows, int columns, int constraint)
rows
- the number of rowscolumns
- - the number of columnsconstraint
- one of ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL, DECIMAL
it can be bitwised or'd with one of PASSWORD, UNEDITABLE, SENSITIVE, NON_PREDICTIVE,
INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD. E.g. ANY | PASSWORD.IllegalArgumentException
- if rows <= 0 or columns <= 1public TextArea(String text, int rows, int columns)
text
- the text to be displayed; if text is null, the empty
string "" will be displayedrows
- the number of rowscolumns
- - the number of columnsIllegalArgumentException
- if rows <= 0 or columns <= 1public TextArea(String text, int rows, int columns, int constraint)
text
- the text to be displayed; if text is null, the empty
string "" will be displayedrows
- the number of rowscolumns
- - the number of columnsconstraint
- one of ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL, DECIMAL
it can be bitwised or'd with one of PASSWORD, UNEDITABLE, SENSITIVE, NON_PREDICTIVE,
INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD. E.g. ANY | PASSWORD.IllegalArgumentException
- if rows <= 0 or columns <= 1public TextArea(String text, int maxSize)
text
- the text to be displayed; if text is null, the empty
string "" will be displayedmaxSize
- text area maximum sizepublic TextArea(String text)
text
- the text to be displayed; if text is null, the empty
string "" will be displayedpublic TextArea()
public static int getDefaultValign()
public static void setDefaultValign(int aDefaultValign)
aDefaultValign
- the defaultValign to setprotected void initComponent()
Component
initComponent
in class Component
protected void deinitialize()
Component
deinitialize
in class Component
protected void initLaf(UIManager uim)
public void setConstraint(int constraint)
constraint
- one of ANY, EMAILADDR, NUMERIC, PHONENUMBER, URL, DECIMAL
it can be bitwised or'd with one of PASSWORD, UNEDITABLE, SENSITIVE, NON_PREDICTIVE,
INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD. E.g. ANY | PASSWORD.public int getConstraint()
setConstraint(int)
public void setWidth(int width)
setWidth
in class Component
width
- the width of the componentComponent.setPreferredSize(com.codename1.ui.geom.Dimension)
public void setText(String t)
setText
in interface TextHolder
t
- new value for the text areapublic String getText()
getText
in interface TextHolder
public int getAsInt(int invalid)
invalid
- in case the text isn't an integer this number will be returnedpublic long getAsLong(long invalid)
invalid
- in case the text isn't a long this number will be returnedpublic double getAsDouble(double invalid)
invalid
- in case the text isn't an double this number will be returnedpublic boolean isEditable()
isEditable
in interface Editable
isEditable
in class Component
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
,
Component.isEditing()
,
Component.startEditingAsync()
,
Component.stopEditing(java.lang.Runnable)
public int getPreferredTabIndex()
Component
Tab index meanings work similar to the HTML tabIndex attribute. A tab Index of -1 (the default value) results in the field not being traversable using the keyboard (or using the next/prev buttons in devices' virtual keyboards). A tab index of 0 results in the component's traversal order being dictated by the natural traversal order of the form.
Use Form.getTabIterator(com.codename1.ui.Component)
to obtain the complete traversal order for
all components in the form.
Best practice is to only explicitly set preferred tabIndex values of 0 if you want the component to be traversable, or -1 if you don't want the component to be traversable. Explicitly setting a positive preferred tab index may result in unexpected results.
When the user tries to "tab" to the next field (or presses the "Next" button on the virtual keyboard), this
triggers a call to Form.getTabIterator(com.codename1.ui.Component)
, crawls the component hierarchy and
returns a ListIterator
of all of the traversable fields in the form in the order they should
be traversed. This order is determined by the layout managers on the form. The core layout managers define
sensible traversal orders by default. If you have a custom layout manager, you can override its traversal
order by implementing the Layout.overridesTabIndices(com.codename1.ui.Container)
and
Layout.getChildrenInTraversalOrder(com.codename1.ui.Container)
methods.
getPreferredTabIndex
in class Component
public void setEditable(boolean b)
b
- true is text are is editable; otherwise falsepublic int getMaxSize()
public void setMaxSize(int maxSize)
maxSize
- the maximum size of the text areapublic void keyPressed(int keyCode)
keyPressed
in class Component
keyCode
- the key code value to indicate a physical key.protected void fireClicked()
fireClicked
in class Component
protected boolean isSelectableInteraction()
isSelectableInteraction
in class Component
public void keyReleased(int keyCode)
keyReleased
in class Component
keyCode
- the key code value to indicate a physical key.public boolean isScrollableY()
isScrollableY
in class Component
public void pointerHover(int[] x, int[] y)
pointerHover
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerHoverReleased(int[] x, int[] y)
pointerHoverReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
pointerReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic int getColumns()
public int getActualRows()
public int getRows()
public void setColumns(int columns)
columns
- number of columnspublic void setRows(int rows)
rows
- number of rowspublic int getLines()
public String getTextAt(int line)
line
- the line number in the text boxprotected char[] preprocess(String text)
text
- the text to processpublic int getRowsGap()
public void setRowsGap(int rowsGap)
rowsGap
- num of pixels to gap between rowspublic void paint(Graphics g)
protected Dimension calcPreferredSize()
calcPreferredSize
in class Component
protected Dimension calcScrollSize()
calcScrollSize
in class Component
public void addActionListener(ActionListener a)
addActionListener
in interface ActionSource
a
- actionListenerpublic void removeActionListener(ActionListener a)
removeActionListener
in interface ActionSource
a
- actionListenerpublic void addCloseListener(ActionListener l)
l
- Form.setCurrentInputDevice(com.codename1.ui.VirtualInputDevice)
public void removeCloseListener(ActionListener l)
public static void setDefaultMaxSize(int value)
value
- default value for the size of the native text boxpublic boolean isGrowByContent()
public void setGrowByContent(boolean growByContent)
growByContent
- true if the text component should grow and false otherwisepublic static void setAutoDegradeMaxSize(boolean value)
value
- new value for autoDegradeMaxSizepublic static boolean isAutoDegradeMaxSize()
public String getUnsupportedChars()
public void setUnsupportedChars(String unsupportedChars)
unsupportedChars
- the unsupported character stringpublic int getLinesToScroll()
public void setLinesToScroll(int linesToScroll)
linesToScroll
- number bigger or equal to 1public static void setWidestChar(char widestC)
widestC
- the widest characterpublic static char getWidestChar()
public void setSingleLineTextArea(boolean singleLineTextArea)
singleLineTextArea
- set to true to force a single line textpublic boolean isSingleLineTextArea()
public void setAlignment(int align)
align
- alignment valueComponent.CENTER
,
Component.LEFT
,
Component.RIGHT
public int getAlignment()
Component.CENTER
,
Component.LEFT
,
Component.RIGHT
public int getAbsoluteAlignment()
Component.CENTER
,
Component.LEFT
,
Component.RIGHT
public boolean isPendingCommit()
public int getCursorPosition()
public int getCursorY()
public int getCursorX()
public boolean isQwertyInput()
public String getInputMode()
public String[] getInputModeOrder()
public boolean isEnableInputScroll()
protected boolean isEnterKey(int keyCode)
keyCode
- the key testedpublic static void autoDetectWidestChar(String s)
s
- string to search using charWidthpublic static boolean isUseStringWidth()
public static void setUseStringWidth(boolean aUseStringWidth)
aUseStringWidth
- the new value for useStringWidthpublic void setHint(String hint)
hint
- the hint text to displaypublic String getHint()
public void setHintIcon(Image icon)
icon
- the iconpublic Image getHintIcon()
public void setHint(String hint, Image icon)
hint
- the hint text to displayicon
- the hint icon to displaypublic Label getHintLabel()
public void setVerticalAlignment(int valign)
NOTE: If the text area is an editable, multi-line text field,
and the platform doesn't support vertical alignment with its native text editor,
then getVerticalAlignment()
will always return Component.TOP
, no
matter what value you set here. Currently no platforms support
vertical alignment of multiline text areas.
valign
- alignment valueComponent.CENTER
,
Component.TOP
,
Component.BOTTOM
public int getVerticalAlignment()
NOTE: If the text area is an editable, multi-line text field,
and the platform doesn't support vertical alignment with its native text editor,
then this will always return Component.TOP
. Currently no platforms support
vertical alignment of multiline text areas.
Component.CENTER
,
Component.TOP
,
Component.BOTTOM
public String[] getBindablePropertyNames()
getBindablePropertyNames
in class Component
public Class[] getBindablePropertyTypes()
getBindablePropertyTypes
in class Component
public void bindProperty(String prop, BindTarget target)
bindProperty
in class Component
prop
- the property nametarget
- the target binderpublic void unbindProperty(String prop, BindTarget target)
unbindProperty
in class Component
prop
- the property namestarget
- the target binderpublic Object getBoundPropertyValue(String prop)
getBoundPropertyValue
in class Component
prop
- the propertypublic void setBoundPropertyValue(String prop, Object value)
setBoundPropertyValue
in class Component
prop
- the property whose value should be setvalue
- the valuepublic int getGrowLimit()
public void setGrowLimit(int growLimit)
growLimit
- the growLimit to setpublic void setEndsWith3Points(boolean endsWith3Points)
endsWith3Points
- true if text should add "..." at the endpublic boolean isEndsWith3Points()
public void registerAsInputDevice()
public void startEditing()
public void startEditingAsync()
startEditingAsync
in interface Editable
startEditingAsync
in class Component
Component.stopEditing(java.lang.Runnable)
,
Component.isEditing()
,
Component.isEditable()
,
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
public boolean isEditing()
isEditing
in interface Editable
isEditing
in class Component
Component.startEditingAsync()
,
Component.stopEditing(java.lang.Runnable)
,
Component.isEditable()
,
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
public void stopEditing()
public void stopEditing(Runnable onFinish)
stopEditing
in interface Editable
stopEditing
in class Component
onFinish
- invoked when editing stoppedComponent.startEditingAsync()
,
Component.isEditing()
,
Component.isEditable()
,
Component.getEditingDelegate()
,
Component.setEditingDelegate(com.codename1.ui.Editable)
public Style getStyle()
public void addDataChangedListener(DataChangedListener d)
d
- the listenerpublic void removeDataChangedListener(DataChangedListener d)
d
- the listenerpublic void addDataChangeListener(DataChangedListener d)
d
- the listenerpublic void removeDataChangeListener(DataChangedListener d)
d
- the listenerpublic void fireDataChanged(int type, int index)
type
- the event type: Added, Removed or Changeindex
- cursor location of the eventpublic void setDoneListener(ActionListener l)
l
- the listenerpublic ActionListener getDoneListener()
public void fireDoneEvent()
public boolean isActAsLabel()
public void setActAsLabel(boolean actAsLabel)
actAsLabel
- the actAsLabel to setprotected boolean shouldRenderComponentSelection()
shouldRenderComponentSelection
in class Component
protected TextSelection.Spans calculateTextSelectionSpan(TextSelection sel)
sel
- The TextSelectionpublic void setTextSelectionEnabled(boolean enabled)
enabled
- setTextSelectionEnabled(boolean)
,
Form.getTextSelection()
,
TextSelection.setEnabled(boolean)
public boolean isTextSelectionEnabled()
Form.getTextSelection()
and TextSelection.setEnabled(boolean)
,
and also ensure that the label's text selection is enabled via setTextSelectionEnabled(boolean)
.setTextSelectionEnabled(boolean)
public TextSelection.TextSelectionSupport getTextSelectionSupport()
getTextSelectionSupport
in class Component