public class TextField extends TextComponent
Modifier and Type | Class and Description |
---|---|
protected class |
TextField.AccessibleAWTTextField |
TextComponent.AccessibleAWTTextComponent
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
textListener
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TextField()
Initializes a new instance of
TextField that is empty
and has one column. |
TextField(int columns)
Initializes a new instance of
TextField that is empty
and has the specified number of columns. |
TextField(String text)
Initializes a new instance of
TextField containing
the specified text. |
TextField(String text,
int columns)
Initializes a new instance of
TextField with the
specified text and number of columns. |
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener listener)
Addes a new listener to the list of action listeners for this
object.
|
void |
addNotify()
Notifies this object that it should create its native peer.
|
boolean |
echoCharIsSet()
Tests whether or not this text field has an echo character set
so that characters the user type are not echoed to the screen.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this
TextComponent . |
ActionListener[] |
getActionListeners()
Return all ActionListeners register to this
TextField object
as an array. |
int |
getColumns()
Returns the number of columns in the field.
|
char |
getEchoChar()
Returns the character that is echoed to the screen when a text
field is protected (such as when a password is being entered).
|
<T extends EventListener> |
getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListeners
upon this
TextField . |
Dimension |
getMinimumSize()
Returns the minimum size for this text field.
|
Dimension |
getMinimumSize(int columns)
Returns the minimum size of a text field with the specified number
of columns.
|
Dimension |
getPreferredSize()
Returns the preferred size for this text field.
|
Dimension |
getPreferredSize(int columns)
Returns the preferred size of a text field with the specified number
of columns.
|
Dimension |
minimumSize()
Deprecated.
This method is deprecated in favor of
getMinimumSize() . |
Dimension |
minimumSize(int columns)
Deprecated.
This method is deprecated in favor of
getMinimumSize(int) . |
protected String |
paramString()
Returns a debug string for this object.
|
Dimension |
preferredSize()
Deprecated.
This method is deprecated in favor of
getPreferredSize() . |
Dimension |
preferredSize(int columns)
Deprecated.
This method is deprecated in favor of
getPreferredSize(int) . |
protected void |
processActionEvent(ActionEvent event)
Processes an action event by calling any registered listeners.
|
protected void |
processEvent(AWTEvent event)
Processes the specified event.
|
void |
removeActionListener(ActionListener listener)
Removes the specified listener from the list of action listeners
for this object.
|
void |
setColumns(int columns)
Sets the number of columns in this field to the specified value.
|
void |
setEchoChar(char echoChar)
Sets the character that is echoed when protected input such as
a password is displayed.
|
void |
setEchoCharacter(char echoChar)
Deprecated.
This method is deprecated in favor of
setEchoChar() |
addTextListener, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processTextEvent, removeNotify, removeTextListener, select, selectAll, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
public TextField()
TextField
that is empty
and has one column.HeadlessException
- If GraphicsEnvironment.isHeadless() is true,public TextField(String text)
TextField
containing
the specified text. The number of columns will be equal to the
length of the text string.text
- The text to display in the field.HeadlessException
- If GraphicsEnvironment.isHeadless() is true,public TextField(int columns)
TextField
that is empty
and has the specified number of columns.columns
- The number of columns in the text field.HeadlessException
- If GraphicsEnvironment.isHeadless() is true,public TextField(String text, int columns)
TextField
with the
specified text and number of columns.text
- The text to display in the field.columns
- The number of columns in the field.HeadlessException
- If GraphicsEnvironment.isHeadless() is true,public int getColumns()
public void setColumns(int columns)
columns
- The new number of columns in the field.IllegalArgumentException
- If columns is less than zero.public char getEchoChar()
public void setEchoChar(char echoChar)
echoChar
- The new echo character.public void setEchoCharacter(char echoChar)
setEchoChar()
echoChar
- The new echo character.public boolean echoCharIsSet()
true
if an echo character is set,
false
otherwise.public Dimension getMinimumSize()
getMinimumSize
in class Component
Component.getPreferredSize()
,
Component.setMinimumSize(Dimension)
,
LayoutManager
public Dimension getMinimumSize(int columns)
columns
- The number of columns to get the minimum size for.public Dimension minimumSize()
getMinimumSize()
.minimumSize
in class Component
public Dimension minimumSize(int columns)
getMinimumSize(int)
.columns
- The number of columns to get the minimum size for.public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getMinimumSize()
,
Component.setPreferredSize(Dimension)
,
LayoutManager
public Dimension getPreferredSize(int columns)
columns
- The number of columns to get the preferred size for.public Dimension preferredSize()
getPreferredSize()
.preferredSize
in class Component
public Dimension preferredSize(int columns)
getPreferredSize(int)
.columns
- The number of columns to get the preferred size for.public void addNotify()
addNotify
in class Component
Component.isDisplayable()
,
Component.removeNotify()
public void addActionListener(ActionListener listener)
listener
- The listener to add to the list.public void removeActionListener(ActionListener listener)
listener
- The listener to remove from the list.protected void processEvent(AWTEvent event)
ActionEvent
then processActionEvent()
is
called to process it, otherwise the event is sent to the
superclass.processEvent
in class TextComponent
event
- The event to process.Component.processComponentEvent(ComponentEvent)
,
Component.processFocusEvent(FocusEvent)
,
Component.processKeyEvent(KeyEvent)
,
Component.processMouseEvent(MouseEvent)
,
Component.processMouseMotionEvent(MouseEvent)
,
Component.processInputMethodEvent(InputMethodEvent)
,
Component.processHierarchyEvent(HierarchyEvent)
,
Component.processMouseWheelEvent(MouseWheelEvent)
protected void processActionEvent(ActionEvent event)
enableEvents()
.event
- The event to process.protected String paramString()
paramString
in class TextComponent
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
TextField
. FooListeners are registered using the
addFooListener method.getListeners
in class TextComponent
listenerType
- the class of listeners to filter (null
not permitted).ClassCastException
- If listenerType doesn't specify a class or
interface that implements java.util.EventListener.Component.getComponentListeners()
,
Component.getFocusListeners()
,
Component.getHierarchyListeners()
,
Component.getHierarchyBoundsListeners()
,
Component.getKeyListeners()
,
Component.getMouseListeners()
,
Component.getMouseMotionListeners()
,
Component.getMouseWheelListeners()
,
Component.getInputMethodListeners()
,
Component.getPropertyChangeListeners()
public ActionListener[] getActionListeners()
TextField
object
as an array.public AccessibleContext getAccessibleContext()
TextComponent
TextComponent
.
The context is created, if necessary.getAccessibleContext
in interface Accessible
getAccessibleContext
in class TextComponent