All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.text.DefaultCaret
java.lang.Object
|
+----java.awt.Component
|
+----com.sun.java.swing.text.DefaultCaret
- public class DefaultCaret
- extends Component
- implements Caret, DocumentListener, ActionListener
An implementation of Caret for a view that maps over
the entire portion of the model represented (ie there are no
holes in the area represented) and renders the insert position
as a vertical line.
The foreground color of the component is the color of the caret
and the background color of the component is the color of the
selections made by moving the caret. The Highlighter implementation
of the associated UI is used to actually render the selection.
- See Also:
- Caret
-
changeEvent
-
-
changeListenerList
-
-
DefaultCaret(Color, Color)
- Constructs a caret with given color settings.
-
actionPerformed(ActionEvent)
- Invoked when the blink timer fires.
-
addChangeListener(ChangeListener)
- Adds a listener to track whenever the caret position has
been changed.
-
adjustHorizontally(BoundedRangeModel, Rectangle, Rectangle)
- Scrolls the associated view horizontally to make
the caret visible.
-
adjustVertically(BoundedRangeModel, Rectangle, Rectangle)
- Scrolls the associated view vertically to make
the caret visible.
-
changedUpdate(DocumentEvent)
- Gives notification that an attribute or set of attributes changed.
-
damage(Rectangle)
- Damages the area surrounding the caret to cause
it to be repainted.
-
deinstall(JTextComponent)
- Called when the UI is being removed from the
interface of a JTextComponent.
-
getActions()
- Fetches the command list for navigating the caret
through the view.
-
getDot()
- Fetches the current position of the caret.
-
getMagicCaretPosition()
- Gets the saved caret position.
-
getMark()
- Fetches the current position of the mark.
-
insertUpdate(DocumentEvent)
- Updates the dot and mark if they were changed by
the insertion.
-
install(JTextComponent)
- Called when the UI is being installed into the
interface of a JTextComponent.
-
isVisible()
- Determines if the caret is currently visible.
-
moveDot(int)
- Moves the caret position to some other position.
-
paint(Graphics)
- Renders the caret as a vertical line.
-
removeChangeListener(ChangeListener)
- Removes a listener that was tracking caret position changes.
-
removeUpdate(DocumentEvent)
- Updates the dot and mark if they were changed
by the removal.
-
setBlinkRate(int)
- Sets the caret blink rate.
-
setDot(int)
- Sets the caret position and mark to some position.
-
setMagicCaretPosition(Point)
- Saves the current caret position.
-
setVisible(boolean)
- Sets the caret visibility.
changeListenerList
protected ChangeListenerList changeListenerList
changeEvent
protected ChangeEvent changeEvent
DefaultCaret
public DefaultCaret(Color c,
Color h)
- Constructs a caret with given color settings.
- Parameters:
- c - the caret color
- h - the highlight color for selections
(that is, indicating the range spaned by the dot/mark
combination)
damage
protected void damage(Rectangle r)
- Damages the area surrounding the caret to cause
it to be repainted. If paint() is reimplemented,
this method should also be reimplemented.
- Parameters:
- r - the current location of the caret
- See Also:
- paint
adjustHorizontally
protected void adjustHorizontally(BoundedRangeModel vis,
Rectangle oloc,
Rectangle nloc)
- Scrolls the associated view horizontally to make
the caret visible. Since how this should be done
is somewhat of a policy, this method can be
reimplemented to change the behavior. By default
an attempt will be made to scroll the view so the
caret is in its previous location.
- Parameters:
- vis - the bounded range
- oloc - the old position
- nloc - the new position
adjustVertically
protected void adjustVertically(BoundedRangeModel vis,
Rectangle oloc,
Rectangle nloc)
- Scrolls the associated view vertically to make
the caret visible. Since how this should be done
is somewhat of a policy, this method can be
reimplemented to change the behavior. By default
an attempt will be made to scroll the view so the
caret is in it's previous location.
- Parameters:
- vis - the bounded range
- oloc - the old position
- nloc - the new position
paint
public void paint(Graphics g)
- Renders the caret as a vertical line. If this is reimplemented
the damage method should also be reimplemented as it assumes the
shape of the caret is a vertical line.
- Parameters:
- g - the graphics context
- Overrides:
- paint in class Component
- See Also:
- damage
actionPerformed
public void actionPerformed(ActionEvent e)
- Invoked when the blink timer fires.
- Parameters:
- e - the action event
insertUpdate
public void insertUpdate(DocumentEvent e)
- Updates the dot and mark if they were changed by
the insertion.
- Parameters:
- e - the document event
- See Also:
- insertUpdate
removeUpdate
public void removeUpdate(DocumentEvent e)
- Updates the dot and mark if they were changed
by the removal.
- Parameters:
- e - the document event
- See Also:
- removeUpdate
changedUpdate
public void changedUpdate(DocumentEvent e)
- Gives notification that an attribute or set of attributes changed.
- Parameters:
- e - the document event
- See Also:
- changedUpdate
install
public void install(JTextComponent c)
- Called when the UI is being installed into the
interface of a JTextComponent. This can be used
to gain access to the model that is being navigated
by the implementation of this interface.
- Parameters:
- c - the component
- See Also:
- install
deinstall
public void deinstall(JTextComponent c)
- Called when the UI is being removed from the
interface of a JTextComponent. This is used to
unregister any listeners that were attached.
- Parameters:
- c - the component
- See Also:
- deinstall
addChangeListener
public void addChangeListener(ChangeListener l)
- Adds a listener to track whenever the caret position has
been changed.
- Parameters:
- l - the listener
- See Also:
- addChangeListener
removeChangeListener
public void removeChangeListener(ChangeListener l)
- Removes a listener that was tracking caret position changes.
- Parameters:
- l - the listener
- See Also:
- removeChangeListener
isVisible
public boolean isVisible()
- Determines if the caret is currently visible.
- Returns:
- true if visible else false
- Overrides:
- isVisible in class Component
- See Also:
- isVisible
setVisible
public void setVisible(boolean e)
- Sets the caret visibility.
- Parameters:
- e - the visibility specifier
- Overrides:
- setVisible in class Component
- See Also:
- setVisible
setBlinkRate
public void setBlinkRate(int rate)
- Sets the caret blink rate.
- Parameters:
- rate - the rate
- See Also:
- setBlinkRate
getDot
public int getDot()
- Fetches the current position of the caret.
- Returns:
- the position
- See Also:
- getDot
getMark
public int getMark()
- Fetches the current position of the mark. If there is a selection,
the dot and mark will not be the same.
- Returns:
- the position
- See Also:
- getMark
setDot
public void setDot(int dot)
- Sets the caret position and mark to some position. This
implicitly sets the selection range to zero.
- Parameters:
- dot - the position
- See Also:
- setDot
moveDot
public void moveDot(int dot)
- Moves the caret position to some other position.
- Parameters:
- dot - the position
- See Also:
- moveDot
getActions
public Action[] getActions()
- Fetches the command list for navigating the caret
through the view.
- Returns:
- the command list
- See Also:
- getActions
setMagicCaretPosition
public void setMagicCaretPosition(Point p)
- Saves the current caret position. This used when
caret up/down actions occur, moving between lines
that have uneven end positions.
- See Also:
- getMagicCaretPosition, DefaultCaret. UpAction, DefaultCaret. DownAction
getMagicCaretPosition
public Point getMagicCaretPosition()
- Gets the saved caret position.
see #setMagicCaretPosition
All Packages Class Hierarchy This Package Previous Next Index