com.vaadin.ui.
Class TextField
java.lang.Object
com.vaadin.ui.AbstractComponent
com.vaadin.ui.AbstractField
com.vaadin.ui.AbstractTextField
com.vaadin.ui.TextField
All Implemented Interfaces:
Buffered, BufferedValidatable, Property, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, FieldEvents.TextChangeNotifier, MethodEventSource, Paintable, Sizeable, VariableOwner, Component, Component.Focusable, Field, Serializable, EventListener
- extends AbstractTextField
public class TextField
A text editor component that can be bound to any bindable Property. The text editor supports both multiline and single line modes, default is one-line mode.
Since TextField
extends AbstractField
it implements
the Buffered
interface. A TextField
is
in write-through mode by default, so
AbstractField.setWriteThrough(boolean)
must be called
to enable buffering.
Since:
3.0
Version:
6.8.18
Author:
Vaadin Ltd.
See Also:
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractTextField |
---|
AbstractTextField.TextChangeEventImpl, AbstractTextField.TextChangeEventMode |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField |
---|
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent |
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent |
---|
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler |
Nested classes/interfaces inherited from interface com.vaadin.ui.Field |
---|
Field.ValueChangeEvent |
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered |
---|
Buffered.SourceException |
Nested classes/interfaces inherited from interface com.vaadin.data.Property |
---|
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Constructor Summary | |
---|---|
TextField()
Constructs an empty TextField with no caption. |
|
TextField(Property dataSource)
Constructs a new TextField that's bound to the specified
Property and has no caption. |
|
TextField(String caption)
Constructs an empty TextField with given caption. |
|
TextField(String caption,
Property dataSource)
Constructs a new TextField that's bound to the specified
Property and has the given caption String . |
|
TextField(String caption,
String value)
Constructs a new TextField with the given caption and
initial text contents. |
Method Summary | |
---|---|
int |
getRows()
Deprecated. Starting from 6.5 use TextArea for a multi-line text
input. |
boolean |
isSecret()
Deprecated. Starting from 6.5 use PasswordField instead for
secret text input. |
boolean |
isWordwrap()
Deprecated. Starting from 6.5 use TextArea for a multi-line text
input. |
void |
paintContent(PaintTarget target)
Paints any needed component-specific things to the given UIDL stream. |
void |
setHeight(float height,
int unit)
Sets the height of the TextField instance. |
void |
setHeight(String height)
Sets the height of the TextField instance. |
void |
setRows(int rows)
Deprecated. Starting from 6.5 use TextArea for a multi-line text
input. |
void |
setSecret(boolean secret)
Deprecated. Starting from 6.5 use PasswordField instead for
secret text input. |
void |
setWordwrap(boolean wordwrap)
Deprecated. Starting from 6.5 use TextArea for a multi-line text
input. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.vaadin.ui.Field |
---|
getDescription, setCaption, setDescription |
Constructor Detail |
---|
TextField
public TextField()
Constructs an empty TextField
with no caption.
TextField
public TextField(String caption)
- Parameters:
caption
- the captionString
for the editor.
Constructs an empty TextField
with given caption.
TextField
public TextField(Property dataSource)
- Parameters:
dataSource
- the Property to be edited with this editor.
Constructs a new TextField
that's bound to the specified
Property
and has no caption.
TextField
public TextField(String caption,
Property dataSource)
- Parameters:
caption
- the captionString
for the editor.dataSource
- the Property to be edited with this editor.
Constructs a new TextField
that's bound to the specified
Property
and has the given caption String
.
TextField
public TextField(String caption,
String value)
- Parameters:
caption
- the captionString
for the editor.text
- the initial text content of the editor.
Constructs a new TextField
with the given caption and
initial text contents. The editor constructed this way will not be bound
to a Property unless
Property.Viewer.setPropertyDataSource(Property)
is called to bind it.
Method Detail |
---|
isSecret
@Deprecated
public boolean isSecret()
- Returns:
true
if the field is used to enter secret information,false
otherwise.
Deprecated. Starting from 6.5 use PasswordField
instead for
secret text input.
Gets the secret property. If a field is used to enter secret information the information is not echoed to display.
setSecret
@Deprecated
public void setSecret(boolean secret)
- Parameters:
secret
- the value specifying if the field is used to enter secret information.
Deprecated. Starting from 6.5 use PasswordField
instead for
secret text input.
Sets the secret property on and off. If a field is used to enter secret information the information is not echoed to display.
paintContent
public void paintContent(PaintTarget target)
throws PaintException
- Overrides:
paintContent
in classAbstractTextField
- Parameters:
target
- the target UIDL stream where the component should paint itself to- Throws:
PaintException
- if the paint operation failed.
Description copied from class: AbstractComponent
Paints any needed component-specific things to the given UIDL stream. The
more general AbstractComponent.paint(PaintTarget)
method handles all general
attributes common to all components, and it calls this method to paint
any component-specific attributes to the UIDL stream.
getRows
@Deprecated
public int getRows()
- Returns:
- number of explicitly set rows.
Deprecated. Starting from 6.5 use TextArea
for a multi-line text
input.
Gets the number of rows in the editor. If the number of rows is set to 0, the actual number of displayed rows is determined implicitly by the adapter.
setRows
@Deprecated
public void setRows(int rows)
- Parameters:
rows
- the number of rows for this editor.
Deprecated. Starting from 6.5 use TextArea
for a multi-line text
input.
Sets the number of rows in the editor.
isWordwrap
@Deprecated
public boolean isWordwrap()
- Returns:
true
if the component is in the word-wrap mode,false
if not.
Deprecated. Starting from 6.5 use TextArea
for a multi-line text
input.
Tests if the editor is in word-wrap mode.
setWordwrap
@Deprecated
public void setWordwrap(boolean wordwrap)
- Parameters:
wordwrap
- the boolean value specifying if the editor should be in word-wrap mode after the call or not.
Deprecated. Starting from 6.5 use TextArea
for a multi-line text
input.
Sets the editor's word-wrap mode on or off.
setHeight
public void setHeight(float height,
int unit)
- Specified by:
setHeight
in interfaceSizeable
- Overrides:
setHeight
in classAbstractComponent
- Parameters:
height
- the height of the object.unit
- the unit used for the width. Possible values includeSizeable.UNITS_PIXELS
,Sizeable.UNITS_POINTS
,Sizeable.UNITS_PICAS
,Sizeable.UNITS_EM
,Sizeable.UNITS_EX
,Sizeable.UNITS_MM
,Sizeable.UNITS_CM
,Sizeable.UNITS_INCH
,Sizeable.UNITS_PERCENTAGE
.- See Also:
AbstractComponent.setHeight(float, int)
Sets the height of the TextField
instance.
Setting height for TextField
also has a side-effect that puts
TextField
into multiline mode (aka "textarea"). Multiline mode
can also be achieved by calling setRows(int)
. The height value
overrides the number of rows set by setRows(int)
.
If you want to set height of single line TextField
, call
setRows(int)
with value 0 after setting the height. Setting rows
to 0 resets the side-effect.
Starting from 6.5 you should use TextArea
instead of
TextField
for multiline text input.
setHeight
public void setHeight(String height)
- Specified by:
setHeight
in interfaceSizeable
- Overrides:
setHeight
in classAbstractComponent
- Parameters:
height
- in CSS style string representation- See Also:
AbstractComponent.setHeight(java.lang.String)
Sets the height of the TextField
instance.
Setting height for TextField
also has a side-effect that puts
TextField
into multiline mode (aka "textarea"). Multiline mode
can also be achieved by calling setRows(int)
. The height value
overrides the number of rows set by setRows(int)
.
If you want to set height of single line TextField
, call
setRows(int)
with value 0 after setting the height. Setting rows
to 0 resets the side-effect.