Methods Summary |
---|
public synchronized void | addActionListener(java.awt.event.ActionListener l)Adds the specified action listener to receive
action events from this text field.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
actionListener = AWTEventMulticaster.add(actionListener, l);
newEventsOnly = true;
|
public void | addNotify()Creates the TextField's peer. The peer allows us to modify the
appearance of the TextField without changing its functionality.
synchronized (getTreeLock()) {
if (peer == null)
peer = getToolkit().createTextField(this);
super.addNotify();
}
|
java.lang.String | constructComponentName()Construct a name for this component. Called by getName() when the
name is null.
synchronized (getClass()) {
return base + nameCounter++;
}
|
public boolean | echoCharIsSet()Indicates whether or not this text field has a
character set for echoing.
An echo character is useful for text fields where
user input should not be echoed to the screen, as in
the case of a text field for entering a password.
return echoChar != 0;
|
boolean | eventEnabled(java.awt.AWTEvent e)
if (e.id == ActionEvent.ACTION_PERFORMED) {
if ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 ||
actionListener != null) {
return true;
}
return false;
}
return super.eventEnabled(e);
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this TextField.
For text fields, the AccessibleContext takes the form of an
AccessibleAWTTextField.
A new AccessibleAWTTextField instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTTextField();
}
return accessibleContext;
|
public synchronized java.awt.event.ActionListener[] | getActionListeners()Returns an array of all the action listeners
registered on this textfield.
return (ActionListener[])(getListeners(ActionListener.class));
|
public int | getColumns()Gets the number of columns in this text field. A column is an
approximate average character width that is platform-dependent.
return columns;
|
public char | getEchoChar()Gets the character that is to be used for echoing.
An echo character is useful for text fields where
user input should not be echoed to the screen, as in
the case of a text field for entering a password.
If echoChar = 0 , user
input is echoed to the screen unchanged.
return echoChar;
|
public T[] | getListeners(java.lang.Class listenerType)Returns an array of all the objects currently registered
as FooListener s
upon this TextField .
FooListener s are registered using the
addFooListener method.
You can specify the listenerType argument
with a class literal, such as
FooListener.class .
For example, you can query a
TextField t
for its action listeners with the following code:
ActionListener[] als = (ActionListener[])(t.getListeners(ActionListener.class));
If no such listeners exist, this method returns an empty array.
EventListener l = null;
if (listenerType == ActionListener.class) {
l = actionListener;
} else {
return super.getListeners(listenerType);
}
return AWTEventMulticaster.getListeners(l, listenerType);
|
public java.awt.Dimension | getMinimumSize(int columns)Gets the minumum dimensions for a text field with
the specified number of columns.
return minimumSize(columns);
|
public java.awt.Dimension | getMinimumSize()Gets the minumum dimensions for this text field.
return minimumSize();
|
public java.awt.Dimension | getPreferredSize(int columns)Gets the preferred size of this text field
with the specified number of columns.
return preferredSize(columns);
|
public java.awt.Dimension | getPreferredSize()Gets the preferred size of this text field.
return preferredSize();
|
private static native void | initIDs()Initialize JNI field and method ids
|
public java.awt.Dimension | minimumSize(int columns)
synchronized (getTreeLock()) {
TextFieldPeer peer = (TextFieldPeer)this.peer;
return (peer != null) ?
peer.minimumSize(columns) :
super.minimumSize();
}
|
public java.awt.Dimension | minimumSize()
synchronized (getTreeLock()) {
return (columns > 0) ?
minimumSize(columns) :
super.minimumSize();
}
|
protected java.lang.String | paramString()Returns a string representing the state of this TextField .
This method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null .
String str = super.paramString();
if (echoChar != 0) {
str += ",echo=" + echoChar;
}
return str;
|
public java.awt.Dimension | preferredSize(int columns)
synchronized (getTreeLock()) {
TextFieldPeer peer = (TextFieldPeer)this.peer;
return (peer != null) ?
peer.preferredSize(columns) :
super.preferredSize();
}
|
public java.awt.Dimension | preferredSize()
synchronized (getTreeLock()) {
return (columns > 0) ?
preferredSize(columns) :
super.preferredSize();
}
|
protected void | processActionEvent(java.awt.event.ActionEvent e)Processes action events occurring on this text field by
dispatching them to any registered
ActionListener objects.
This method is not called unless action events are
enabled for this component. Action events are enabled
when one of the following occurs:
- An
ActionListener object is registered
via addActionListener .
- Action events are enabled via
enableEvents .
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
ActionListener listener = actionListener;
if (listener != null) {
listener.actionPerformed(e);
}
|
protected void | processEvent(java.awt.AWTEvent e)Processes events on this text field. If the event
is an instance of ActionEvent ,
it invokes the processActionEvent
method. Otherwise, it invokes processEvent
on the superclass.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
if (e instanceof ActionEvent) {
processActionEvent((ActionEvent)e);
return;
}
super.processEvent(e);
|
private void | readObject(java.io.ObjectInputStream s)Read the ObjectInputStream and if it isn't null,
add a listener to receive action events fired by the
TextField. Unrecognized keys or values will be
ignored.
// HeadlessException will be thrown by TextComponent's readObject
s.defaultReadObject();
// Make sure the state we just read in for columns has legal values
if (columns < 0) {
columns = 0;
}
// Read in listeners, if any
Object keyOrNull;
while(null != (keyOrNull = s.readObject())) {
String key = ((String)keyOrNull).intern();
if (actionListenerK == key) {
addActionListener((ActionListener)(s.readObject()));
} else {
// skip value for unrecognized key
s.readObject();
}
}
|
public synchronized void | removeActionListener(java.awt.event.ActionListener l)Removes the specified action listener so that it no longer
receives action events from this text field.
If l is null, no exception is thrown and no action is performed.
if (l == null) {
return;
}
actionListener = AWTEventMulticaster.remove(actionListener, l);
|
public synchronized void | setColumns(int columns)Sets the number of columns in this text field. A column is an
approximate average character width that is platform-dependent.
int oldVal = this.columns;
if (columns < 0) {
throw new IllegalArgumentException("columns less than zero.");
}
if (columns != oldVal) {
this.columns = columns;
invalidate();
}
|
public void | setEchoChar(char c)Sets the echo character for this text field.
An echo character is useful for text fields where
user input should not be echoed to the screen, as in
the case of a text field for entering a password.
Setting echoChar = 0 allows
user input to be echoed to the screen again.
setEchoCharacter(c);
|
public synchronized void | setEchoCharacter(char c)
if (echoChar != c) {
echoChar = c;
TextFieldPeer peer = (TextFieldPeer)this.peer;
if (peer != null) {
peer.setEchoCharacter(c);
}
}
|
public void | setText(java.lang.String t)Sets the text that is presented by this
text component to be the specified text.
super.setText(t);
// This could change the preferred size of the Component.
if (valid) {
invalidate();
}
|
private void | writeObject(java.io.ObjectOutputStream s)Writes default serializable fields to stream. Writes
a list of serializable ActionListener(s) as optional data.
The non-serializable ActionListener(s) are detected and
no attempt is made to serialize them.
s.defaultWriteObject();
AWTEventMulticaster.save(s, actionListenerK, actionListener);
s.writeObject(null);
|