|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.TextComponent
The TextComponent
class is the superclass of
any component that allows the editing of some text.
A text component embodies a string of text. The
TextComponent
class defines a set of methods
that determine whether or not this text is editable. If the
component is editable, it defines another set of methods
that supports a text insertion caret.
In addition, the class defines methods that are used to maintain a current selection from the text. The text selection, a substring of the component's text, is the target of editing operations. It is also referred to as the selected text.
Inner classes inherited from class java.awt.Component |
Component.AWTTreeLock,
Component.NativeInLightFixer |
Field Summary | |
private boolean |
canAccessClipboard
true if this TextComponent has access to the System clipboard |
(package private) boolean |
editable
A boolean indicating whether or not this TextComponent is editable. |
(package private) int |
selectionEnd
The selection refers to the selected text, and the selectionEnd is the end position of the selected text. |
(package private) int |
selectionStart
The selection refers to the selected text, and the selectionStart is the start position of the selected text. |
private static long |
serialVersionUID
|
(package private) String |
text
The value of the text. |
private int |
textComponentSerializedDataVersion
The textComponent SerializedDataVersion. |
protected TextListener |
textListener
|
Constructor Summary | |
(package private) |
TextComponent(String text)
Constructs a new text component initialized with the specified text. |
Method Summary | |
void |
addTextListener(TextListener l)
Adds the specified text event listener to recieve text events from this textcomponent. |
(package private) boolean |
areInputMethodsEnabled()
|
private void |
checkSystemClipboardAccess()
Assigns a valid value to the canAccessClipboard instance variable. |
private void |
enableInputMethodsIfNecessary()
|
(package private) boolean |
eventEnabled(AWTEvent e)
|
int |
getCaretPosition()
Gets the position of the text insertion caret for this text component. |
String |
getSelectedText()
Gets the selected text from the text that is presented by this text component. |
int |
getSelectionEnd()
Gets the end position of the selected text in this text component. |
int |
getSelectionStart()
Gets the start position of the selected text in this text component. |
String |
getText()
Gets the text that is presented by this text component. |
boolean |
isEditable()
Indicates whether or not this text component is editable. |
protected String |
paramString()
Returns the parameter string representing the state of this text component. |
protected void |
processEvent(AWTEvent e)
Processes events on this textcomponent. |
protected void |
processTextEvent(TextEvent e)
Processes text events occurring on this text component by dispatching them to any registered TextListener objects. |
private void |
readObject(ObjectInputStream s)
Read the ObjectInputStream and if it isnt null add a listener to receive item events fired by the TextComponent. |
void |
removeNotify()
Removes the TextComponent's peer. |
void |
removeTextListener(TextListener l)
Removes the specified text event listener so that it no longer receives text events from this textcomponent If l is null, no exception is thrown and no action is performed. |
void |
select(int selectionStart,
int selectionEnd)
Selects the text between the specified start and end positions. |
void |
selectAll()
Selects all the text in this text component. |
void |
setCaretPosition(int position)
Sets the position of the text insertion caret for this text component. |
void |
setEditable(boolean b)
Sets the flag that determines whether or not this text component is editable. |
void |
setSelectionEnd(int selectionEnd)
Sets the selection end for this text component to the specified position. |
void |
setSelectionStart(int selectionStart)
Sets the selection start for this text component to the specified position. |
void |
setText(String t)
Sets the text that is presented by this text component to be the specified text. |
private void |
writeObject(ObjectOutputStream s)
Writes default serializable fields to stream. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
Field Detail |
String text
setText()
,
getText()
boolean editable
true
if the text componet
is editable and false
if not.isEditable()
int selectionStart
getSelectionStart()
,
setSelectionStart()
int selectionEnd
getSelectionEnd()
,
setSelectionEnd()
private transient boolean canAccessClipboard
protected transient TextListener textListener
private static final long serialVersionUID
private int textComponentSerializedDataVersion
Constructor Detail |
TextComponent(String text)
Cursor.TEXT_CURSOR
.text
- the initial text that the component presents.Cursor
Method Detail |
private void enableInputMethodsIfNecessary()
boolean areInputMethodsEnabled()
public void removeNotify()
public void setText(String t)
t
- the new text.
If this parameter is null
then
the text is set to the empty string "".getText()
public String getText()
setText(java.lang.String)
public String getSelectedText()
select(int, int)
public boolean isEditable()
true
if this text component is
editable; false
otherwise.setEditable(boolean)
public void setEditable(boolean b)
If the flag is set to true
, this text component
becomes user editable. If the flag is set to false
,
the user cannot change the text of this text component.
t
- a flag indicating whether this text component
should be user editable.isEditable()
public int getSelectionStart()
setSelectionStart(int)
,
getSelectionEnd()
public void setSelectionStart(int selectionStart)
selectionStart
that is out of bounds, the method enforces these constraints
silently, and without failure.selectionStart
- the start position of the
selected text.getSelectionStart()
,
setSelectionEnd(int)
public int getSelectionEnd()
setSelectionEnd(int)
,
getSelectionStart()
public void setSelectionEnd(int selectionEnd)
selectionEnd
that is out of bounds, the method enforces these constraints
silently, and without failure.selectionEnd
- the end position of the
selected text.getSelectionEnd()
,
setSelectionStart(int)
public void select(int selectionStart, int selectionEnd)
This method sets the start and end positions of the selected text, enforcing the restriction that the start position must be greater than or equal to zero. The end position must be greater than or equal to the start position, and less than or equal to the length of the text component's text. The character positions are indexed starting with zero. The length of the selection is endPosition-startPosition, so the character at endPosition is not selected. If the start and end positions of the selected text are equal, all text is deselected. If the caller supplies values that are inconsistent or out of bounds, the method enforces these constraints silently, and without failure.
selectionStart
- the zero-based index of the first
character to be selected.selectionEnd
- the zero-based end position of the
text to be selected. The character at
selectionEnd is not selected.setSelectionStart(int)
,
setSelectionEnd(int)
,
selectAll()
public void selectAll()
public void setCaretPosition(int position)
position
- the position of the text insertion caret.position
is less than zero.public int getCaretPosition()
public void addTextListener(TextListener l)
l
- the text event listenerpublic void removeTextListener(TextListener l)
l
- the text listener.TextListener
,
java.awt.Button#addTextListener
boolean eventEnabled(AWTEvent e)
protected void processEvent(AWTEvent e)
e
- the eventprotected void processTextEvent(TextEvent e)
e
- the text eventComponent.enableEvents(long)
protected String paramString()
private void checkSystemClipboardAccess()
private void writeObject(ObjectOutputStream s) throws IOException
AWTEventMulticaster.save(ObjectOutputStream, String, EventListener)
,
java.awt.Component.itemListenerK
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
removeActionListener()
,
addActionListener()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |