public interface Caret
A place within a document view that represents where things can be inserted into the document model. A caret has a position in the document referred to as a dot. The dot is where the caret is currently located in the model. There is a second position maintained by the caret that represents the other end of a selection called mark. If there is no selection the dot and mark will be equal. If a selection exists, the two values will be different.
The dot can be placed by either calling setDot or moveDot. Setting the dot has the effect of removing any selection that may have previously existed. The dot and mark will be equal. Moving the dot has the effect of creating a selection as the mark is left at whatever position it previously had.
Method Summary | |
---|---|
void |
addChangeListener
(
ChangeListener
l) Adds a listener to track whenever the caret position has been changed. |
void |
deinstall
(
JTextComponent
c) Called when the UI is being removed from the interface of a JTextComponent. |
int |
getBlinkRate
() Gets the blink rate of the caret. |
int |
getDot
() Fetches the current position of the caret. |
Point |
getMagicCaretPosition
() Gets the current caret visual location. |
int |
getMark
() Fetches the current position of the mark. |
void |
install
(
JTextComponent
c) Called when the UI is being installed into the interface of a JTextComponent. |
boolean |
isSelectionVisible
() Determines if the selection is currently visible. |
boolean |
isVisible
() Determines if the caret is currently visible. |
void |
moveDot
(int dot) Moves the caret position (dot) to some other position, leaving behind the mark. |
void |
paint
(
Graphics
g) Renders the caret. |
void |
removeChangeListener
(
ChangeListener
l) Removes a listener that was tracking caret position changes. |
void |
setBlinkRate
(int rate) Sets the blink rate of the caret. |
void |
setDot
(int dot) Sets the caret position to some position. |
void |
setMagicCaretPosition
(
Point
p) Set the current caret visual location. |
void |
setSelectionVisible
(boolean v) Sets the visibility of the selection |
void |
setVisible
(boolean v) Sets the visibility of the caret. |
Method Detail |
---|
void install(JTextComponent c)
void deinstall(JTextComponent c)
void paint(Graphics g)
void addChangeListener(ChangeListener l)
void removeChangeListener(ChangeListener l)
boolean isVisible()
void setVisible(boolean v)
boolean isSelectionVisible()
void setSelectionVisible(boolean v)
void setMagicCaretPosition(Point p)
Point getMagicCaretPosition()
void setBlinkRate(int rate)
int getBlinkRate()
int getDot()
int getMark()
void setDot(int dot)
If the parameter is negative or beyond the length of the document, the caret is placed at the beginning or at the end, respectively.
void moveDot(int dot)