dog.gui
Class DTextField

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--dog.gui.DContainer
                    |
                    +--dog.gui.DTextComponent
                          |
                          +--dog.gui.DTextField
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable, TimerListener

public class DTextField
extends DTextComponent
implements TimerListener

A component that allows the editing of a single line of text.

You can specify an alignment (LEFT, CENTER, or RIGHT) for the text within the component.

You can also choose to have the text echoed with a specified character for password fields.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  java.awt.event.ActionListener actionListener
           
protected  int align
          The alignment of the text in the field.
static int CENTER
          The center alignment.
protected  int columns
          The number of columns in the DTextField.
protected  char echoChar
          The echo character.
protected  boolean filled
          Is this component filled?
protected  boolean focus
          Do we currently have the focus?
static int LEFT
          The left alignment.
static int RIGHT
          The right alignment.
 
Fields inherited from class dog.gui.DTextComponent
editable, position, selectionEnd, selectionStart, text, textListener
 
Fields inherited from class dog.gui.DContainer
cancelButton, defaultButton, EAST, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, tooltip, WEST
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DTextField()
          Constructs a new text field.
DTextField(java.lang.String text)
          Constructs a new text field initialized with the specified text.
DTextField(java.lang.String text, int align)
          Constructs a new text field with the specified text and alignment.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this component.
 boolean echoCharIsSet()
          Returns true if this text field has a character set for echoing.
 int getAlign()
          Returns the alignment of the text in this text field.
 int getColumns()
          Returns the number of columns in this text field.
 char getEchoChar()
          Returns the character to be used for echoing.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size for this component.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size for this component.
 boolean isFilled()
          Indicates whether this component is filled.
 boolean isFocusTraversable()
          This component is focus-traversable if it is not disabled.
 void paint(java.awt.Graphics g)
          Paints this choice.
protected  java.lang.String paramString()
          Returns a parameter string for this component.
protected  void processActionEvent(java.awt.event.ActionEvent event)
          Processes action events occurring on this component by dispatching them to any registered ActionListener objects.
protected  void processEvent(java.awt.AWTEvent event)
          Processes events on this component.
protected  void processFocusEvent(java.awt.event.FocusEvent event)
          Process focus events.
protected  void processKeyEvent(java.awt.event.KeyEvent event)
          Process key events.
protected  void processMouseEvent(java.awt.event.MouseEvent event)
          Process mouse events.
protected  void processMouseMotionEvent(java.awt.event.MouseEvent event)
          Process mouse motion events.
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified action listener so that it no longer receives action events from this component.
 void setAlign(int align)
          Sets the alignment of the text in this text field.
 void setColumns(int columns)
          Sets the number of columns for this text field.
 void setEchoChar(char echoChar)
          Sets the echo character for this text field.
 void setFilled(boolean filled)
          Sets whether to fill this component with the fill colour.
 void setText(java.lang.String text)
          Sets the text in this component, up to the first newline character in the specified input.
 void timerFired(TimerEvent event)
          The timer fired, blink the caret.
 void update(java.awt.Graphics g)
          Updates this component's graphics context.
 
Methods inherited from class dog.gui.DTextComponent
addTextListener, copySelection, cutSelection, deleteLeft, deleteRight, deleteSelection, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, insert, insert, isEditable, lostOwnership, moveLeft, moveLineEnd, moveLineStart, moveRight, moveWordLeft, moveWordRight, pasteSelection, processTextEvent, removeTextListener, select, selectAll, setEditable, setSelectionEnd, setSelectionStart
 
Methods inherited from class dog.gui.DContainer
addImpl, addPropertyChangeListener, alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, getCancelButton, getComponent, getDefaultButton, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getTooltip, isPreloadImages, processCancelAction, processDefaultAction, removePropertyChangeListener, setCancelButton, setDefaultButton, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
The center alignment.

LEFT

public static final int LEFT
The left alignment.

RIGHT

public static final int RIGHT
The right alignment.

align

protected int align
The alignment of the text in the field.

filled

protected boolean filled
Is this component filled?

echoChar

protected char echoChar
The echo character.

columns

protected int columns
The number of columns in the DTextField.

focus

protected transient boolean focus
Do we currently have the focus?

actionListener

protected transient java.awt.event.ActionListener actionListener
Constructor Detail

DTextField

public DTextField()
Constructs a new text field.

DTextField

public DTextField(java.lang.String text)
Constructs a new text field initialized with the specified text.
Parameters:
text - the text to be displayed

DTextField

public DTextField(java.lang.String text,
                  int align)
Constructs a new text field with the specified text and alignment.
Parameters:
text - the text to be displayed
align - LEFT, CENTER, or RIGHT
Method Detail

setText

public void setText(java.lang.String text)
Sets the text in this component, up to the first newline character in the specified input. Tabs are stripped from the text.
Overrides:
setText in class DTextComponent
Parameters:
text - the new text to be set

getAlign

public int getAlign()
Returns the alignment of the text in this text field.
See Also:
setAlign(int)

setAlign

public void setAlign(int align)
Sets the alignment of the text in this text field.
Parameters:
align - LEFT, CENTER, or RIGHT
Throws:
java.lang.IllegalArgumentException - if the alignment is not one of the above.
See Also:
getAlign()

getEchoChar

public char getEchoChar()
Returns the character to be used for echoing.
See Also:
setEchoChar(char), echoCharIsSet()

setEchoChar

public void setEchoChar(char echoChar)
Sets the echo character for this text field. This is useful for fields where the user input shouldn't be echoed to the screen, as in the case of a text field that represents a password.
Parameters:
c - the echo character for this field
See Also:
echoCharIsSet(), getEchoChar()

echoCharIsSet

public boolean echoCharIsSet()
Returns true if this text field has a character set for echoing.
See Also:
setEchoChar(char), getEchoChar()

isFilled

public boolean isFilled()
Indicates whether this component is filled.

setFilled

public void setFilled(boolean filled)
Sets whether to fill this component with the fill colour.

getColumns

public int getColumns()
Returns the number of columns in this text field.
See Also:
setColumns(int)

setColumns

public void setColumns(int columns)
Sets the number of columns for this text field.
Parameters:
columns - the number of columns.
Throws:
java.lang.IllegalArgumentException - if the value supplied for columns is less than zero.
See Also:
getColumns()

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size for this component.
Overrides:
getMinimumSize in class java.awt.Container

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size for this component.
Overrides:
getPreferredSize in class java.awt.Container

update

public void update(java.awt.Graphics g)
Updates this component's graphics context.
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics g)
Paints this choice.
Overrides:
paint in class java.awt.Container

isFocusTraversable

public boolean isFocusTraversable()
This component is focus-traversable if it is not disabled.
Overrides:
isFocusTraversable in class java.awt.Component

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this component.
Parameters:
listener - the action listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener so that it no longer receives action events from this component.
Parameters:
listener - the action listener

processEvent

protected void processEvent(java.awt.AWTEvent event)
Processes events on this component. If the event is an ActionEvent, it invokes the processActionEvent method, else it invokes its superclass's processEvent.
Overrides:
processEvent in class DTextComponent
Parameters:
event - the event

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent event)
Processes action events occurring on this component by dispatching them to any registered ActionListener objects.
Parameters:
event - the action event

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent event)
Process focus events.
Overrides:
processFocusEvent in class java.awt.Component

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent event)
Process key events.
Overrides:
processKeyEvent in class java.awt.Component

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent event)
Process mouse events.
Overrides:
processMouseEvent in class DContainer

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent event)
Process mouse motion events.
Overrides:
processMouseMotionEvent in class DContainer

timerFired

public void timerFired(TimerEvent event)
The timer fired, blink the caret.
Specified by:
timerFired in interface TimerListener

paramString

protected java.lang.String paramString()
Returns a parameter string for this component.
Overrides:
paramString in class DTextComponent