charvax.swing

Class JTextField

Known Direct Subclasses:
CapsTextField, JPasswordField

public class JTextField
extends JTextComponent

JTextField is a component that allows the display and editing of a single line of text. The JTextField class, being a subclass of JComponent, has a setBorder() method which allows an optional Border to be set.

Field Summary

protected Vector
_actionListeners
A list of ActionListeners registered for this component.
protected boolean
_bold
protected int
_columns
protected int
_offset
Index (from the start of the string) of the character displayed in the left corner of the field.
protected String
_padding
A blank-filled string the same length as the JTextField.

Fields inherited from class charvax.swing.text.JTextComponent

_caretPosition, _document, _editable

Fields inherited from class charvax.swing.JComponent

_border

Fields inherited from class charva.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT, _alignmentX, _alignmentY, _background, _cursesColor, _enabled, _focusListeners, _foreground, _keyListeners, _origin, _parent, _visible

Constructor Summary

JTextField()
Construct a text field.
JTextField(String text_)
Use this constructor when you want to initialize the value.
JTextField(String text_, int length_)
Use this constructor when you want to set both the initial value and the length.
JTextField(int length_)
Use this constructor when you want to leave the text field empty but set its length.

Method Summary

void
addActionListener(ActionListener al_)
Register an ActionListener object for this component.
void
debug(int level_)
void
draw()
Called by this JTextField's parent container.
String
getActionCommand()
Get the action command
int
getColumns()
Return the number of columns in the text field.
int
getHeight()
Dimension
getSize()
Return the size of the text field.
int
getWidth()
boolean
isEditable()
Dimension
minimumSize()
Called by the LayoutManager.
void
postActionEvent(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this component.
protected void
processEvent(AWTEvent evt_)
Process events.
void
processKeyEvent(KeyEvent ke_)
Process KeyEvents that have been generated by this JTextField.
void
processMouseEvent(MouseEvent e_)
Process a MouseEvent that was generated by clicking the mouse somewhere inside this JTextField.
void
requestFocus()
void
setActionCommand(String cmd_)
Set the action command
void
setColumns(int columns_)
Sets the number of columns in this Textfield, and then invalidates the layout.
void
setEditable(boolean editable_)
Sets whether this textfield can be edited.
void
setFont(Font font_)
void
setText(String text_)
Set the text that is presented by this JTextField.
String
toString()
Returns a String representation of this component.

Methods inherited from class charvax.swing.text.JTextComponent

getCaretPosition, getDocument, getText, isEditable, setCaretPosition, setDocument, setEditable, setText

Methods inherited from class charvax.swing.JComponent

draw, getBorder, getInsets, setBorder

Methods inherited from class charva.awt.Component

addFocusListener, addKeyListener, contains, contains, debug, draw, getAlignmentX, getAlignmentY, getAncestorWindow, getBackground, getBounds, getCursesColor, getForeground, getHeight, getLocation, getLocationOnScreen, getName, getParent, getSize, getWidth, hasFocus, hide, invalidate, isDisplayed, isEnabled, isFocusTraversable, isTotallyObscured, isValid, isVisible, minimumSize, processEvent, processFocusEvent, processKeyEvent, processMouseEvent, repaint, requestFocus, requestSync, setBackground, setEnabled, setForeground, setLocation, setLocation, setName, setParent, setVisible, show, validate, validateCursesColor

Field Details

_actionListeners

protected Vector _actionListeners
A list of ActionListeners registered for this component.

_bold

protected boolean _bold

_columns

protected int _columns

_offset

protected int _offset
Index (from the start of the string) of the character displayed in the left corner of the field. This is always 0 if the string is shorter than the field.

_padding

protected String _padding
A blank-filled string the same length as the JTextField.

Constructor Details

JTextField

public JTextField()
Construct a text field. The initial string is empty and the number of columns is 10.

JTextField

public JTextField(String text_)
Use this constructor when you want to initialize the value.

JTextField

public JTextField(String text_,
                  int length_)
Use this constructor when you want to set both the initial value and the length.

JTextField

public JTextField(int length_)
Use this constructor when you want to leave the text field empty but set its length.

Method Details

addActionListener

public void addActionListener(ActionListener al_)
Register an ActionListener object for this component.

debug

public void debug(int level_)
Overrides:
debug in interface Component

draw

public void draw()
Called by this JTextField's parent container.
Overrides:
draw in interface JComponent

getActionCommand

public String getActionCommand()
Get the action command

getColumns

public int getColumns()
Return the number of columns in the text field.

getHeight

public int getHeight()
Overrides:
getHeight in interface Component

getSize

public Dimension getSize()
Return the size of the text field. Overrides the method in the Component superclass.
Overrides:
getSize in interface Component

getWidth

public int getWidth()
Overrides:
getWidth in interface Component

isEditable

public boolean isEditable()
Overrides:
isEditable in interface JTextComponent

minimumSize

public Dimension minimumSize()
Called by the LayoutManager.
Overrides:
minimumSize in interface Component

postActionEvent

public void postActionEvent(ActionEvent ae_)
Invoke all the ActionListener callbacks that may have been registered for this component.

processEvent

protected void processEvent(AWTEvent evt_)
Process events.
Overrides:
processEvent in interface Component

processKeyEvent

public void processKeyEvent(KeyEvent ke_)
Process KeyEvents that have been generated by this JTextField.
Overrides:
processKeyEvent in interface Component

processMouseEvent

public void processMouseEvent(MouseEvent e_)
Process a MouseEvent that was generated by clicking the mouse somewhere inside this JTextField. Clicking the mouse inside the JTextField moves the caret position to where the mouse was clicked.
Overrides:
processMouseEvent in interface Component

requestFocus

public void requestFocus()
Overrides:
requestFocus in interface Component

setActionCommand

public void setActionCommand(String cmd_)
Set the action command

setColumns

public void setColumns(int columns_)
Sets the number of columns in this Textfield, and then invalidates the layout.

setEditable

public void setEditable(boolean editable_)
Sets whether this textfield can be edited.
Overrides:
setEditable in interface JTextComponent

setFont

public void setFont(Font font_)

setText

public void setText(String text_)
Set the text that is presented by this JTextField. This method is thread-safe, although most Charva methods are not.
Overrides:
setText in interface JTextComponent

toString

public String toString()
Returns a String representation of this component.