dog.gui
Class DTextComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--dog.gui.DContainer
                    |
                    +--dog.gui.DTextComponent
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable
Direct Known Subclasses:
DSpinbox, DTextArea, DTextField

public abstract class DTextComponent
extends DContainer
implements java.awt.datatransfer.ClipboardOwner

A bean that allows the editing of some text.

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  boolean editable
          A boolean indicating whether or not this TextComponent is editable.
protected  int position
          The caret position.
protected  int selectionEnd
          The selection end.
protected  int selectionStart
          The selection start.
protected  java.lang.String text
          The value of the text.
protected  java.awt.event.TextListener textListener
           
 
Fields inherited from class dog.gui.DContainer
cancelButton, CENTER, 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
 
Method Summary
 void addTextListener(java.awt.event.TextListener listener)
          Adds the specified text event listener to recieve text events from this DTextComponent.
 void copySelection()
          Copies the selected text to the clipboard.
 void cutSelection()
          Cuts the selected text to the clipboard.
 void deleteLeft()
          Deletes the character to the left of the caret.
 void deleteRight()
          Deletes the character to the right of the caret.
 void deleteSelection()
          Removes the selected text.
 int getCaretPosition()
          Returns the position of the text insertion caret for the DTextComponent.
 java.lang.String getSelectedText()
          Returns the selected text contained in this DTextComponent.
 int getSelectionEnd()
          Returns the selected text's end position.
 int getSelectionStart()
          Returns the selected text's start position.
 java.lang.String getText()
          Returns the text contained in this DTextComponent.
 void insert(char ch, boolean selected)
          Inserts the specified character at the current caret position.
 void insert(java.lang.String text, boolean selected)
          Inserts the specified text at the current caret position.
 boolean isEditable()
          Returns the boolean indicating whether this DTextComponent is editable or not.
 void lostOwnership(java.awt.datatransfer.Clipboard clipboard, java.awt.datatransfer.Transferable contents)
          Required because we are a clipboard owner, but does not actually do anything.
 void moveLeft(boolean selected)
          Moves the caret one character left.
 void moveLineEnd(boolean selected)
          Moves the caret to the end of the line.
 void moveLineStart(boolean selected)
          Moves the caret to the start of the line.
 void moveRight(boolean selected)
          Moves the caret one character right.
 void moveWordLeft(boolean selected)
          Moves the caret one word left.
 void moveWordRight(boolean selected)
          Moves the caret one word right.
protected  java.lang.String paramString()
          Returns the parameter string for this component.
 void pasteSelection()
          Pastes the text in the clipboard into this component.
protected  void processEvent(java.awt.AWTEvent event)
          Processes events on this component.
protected  void processTextEvent(java.awt.event.TextEvent event)
          Processes text events occurring on this component by dispatching them to any registered TextListener objects.
 void removeTextListener(java.awt.event.TextListener listener)
          Removes the specified text event listener so that it no longer receives text events from this DTextComponent
 void select(int selectionStart, int selectionEnd)
          Selects the text found between the specified start and end locations.
 void selectAll()
          Selects all the text in the DTextComponent.
 void setEditable(boolean editable)
          Sets the specified boolean to indicate whether or not this DTextComponent should be editable.
 void setSelectionEnd(int selectionEnd)
          Sets the selection end to the specified position.
 void setSelectionStart(int selectionStart)
          Sets the selection start to the specified position.
protected  void setText(java.lang.String text)
          Sets the text of this DTextComponent to the specified text.
 
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, processMouseEvent, processMouseMotionEvent, 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, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, 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, isFocusTraversable, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, 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

text

protected java.lang.String text
The value of the text.

editable

protected boolean editable
A boolean indicating whether or not this TextComponent is editable.

position

protected int position
The caret position.

selectionStart

protected int selectionStart
The selection start.

selectionEnd

protected int selectionEnd
The selection end.

textListener

protected transient java.awt.event.TextListener textListener
Method Detail

getText

public java.lang.String getText()
Returns the text contained in this DTextComponent.
See Also:
setText(java.lang.String)

setText

protected void setText(java.lang.String text)
Sets the text of this DTextComponent to the specified text.
Parameters:
text - the new text to be set
See Also:
getText()

getSelectedText

public java.lang.String getSelectedText()
Returns the selected text contained in this DTextComponent.
See Also:
setText(java.lang.String)

isEditable

public boolean isEditable()
Returns the boolean indicating whether this DTextComponent is editable or not.
See Also:
setEditable(boolean)

setEditable

public void setEditable(boolean editable)
Sets the specified boolean to indicate whether or not this DTextComponent should be editable.
Parameters:
editable - the boolean to be set
See Also:
isEditable()

getSelectionStart

public int getSelectionStart()
Returns the selected text's start position.

setSelectionStart

public void setSelectionStart(int selectionStart)
Sets the selection start to the specified position. The new starting point is constrained to be before or at the current selection end.
Parameters:
selectionStart - the start position of the text

getSelectionEnd

public int getSelectionEnd()
Returns the selected text's end position.

setSelectionEnd

public void setSelectionEnd(int selectionEnd)
Sets the selection end to the specified position. The new end point is constrained to be at or after the current selection start.
Parameters:
selectionEnd - the start position of the text

select

public void select(int selectionStart,
                   int selectionEnd)
Selects the text found between the specified start and end locations.
Parameters:
selectionStart - the start position of the text
selectionEnd - the end position of the text

selectAll

public void selectAll()
Selects all the text in the DTextComponent.

getCaretPosition

public int getCaretPosition()
Returns the position of the text insertion caret for the DTextComponent.
Returns:
the position of the text insertion caret.

cutSelection

public void cutSelection()
Cuts the selected text to the clipboard.

copySelection

public void copySelection()
Copies the selected text to the clipboard.

pasteSelection

public void pasteSelection()
Pastes the text in the clipboard into this component.

lostOwnership

public void lostOwnership(java.awt.datatransfer.Clipboard clipboard,
                          java.awt.datatransfer.Transferable contents)
Required because we are a clipboard owner, but does not actually do anything.
Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner

moveLeft

public void moveLeft(boolean selected)
Moves the caret one character left.

moveRight

public void moveRight(boolean selected)
Moves the caret one character right.

moveWordLeft

public void moveWordLeft(boolean selected)
Moves the caret one word left.

moveWordRight

public void moveWordRight(boolean selected)
Moves the caret one word right.

moveLineStart

public void moveLineStart(boolean selected)
Moves the caret to the start of the line.

moveLineEnd

public void moveLineEnd(boolean selected)
Moves the caret to the end of the line.

deleteSelection

public void deleteSelection()
Removes the selected text.

deleteRight

public void deleteRight()
Deletes the character to the right of the caret.

deleteLeft

public void deleteLeft()
Deletes the character to the left of the caret.

insert

public void insert(char ch,
                   boolean selected)
Inserts the specified character at the current caret position.

insert

public void insert(java.lang.String text,
                   boolean selected)
Inserts the specified text at the current caret position.

addTextListener

public void addTextListener(java.awt.event.TextListener listener)
Adds the specified text event listener to recieve text events from this DTextComponent.
Parameters:
listener - the text event listener

removeTextListener

public void removeTextListener(java.awt.event.TextListener listener)
Removes the specified text event listener so that it no longer receives text events from this DTextComponent

processEvent

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

processTextEvent

protected void processTextEvent(java.awt.event.TextEvent event)
Processes text events occurring on this component by dispatching them to any registered TextListener objects. NOTE: This method will not be called unless text events are enabled for this component; this happens when one of the following occurs: a) A TextListener object is registered via addTextListener() b) Text events are enabled via enableEvents()
Parameters:
e - the text event
See Also:
Component.enableEvents(long)

paramString

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