public interface Caret
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.
Modifier and Type | Method and Description |
---|---|
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.
|
void install(JTextComponent c)
c
- the JTextComponentvoid deinstall(JTextComponent c)
c
- the JTextComponentvoid paint(Graphics g)
g
- the graphics contextvoid addChangeListener(ChangeListener l)
l
- the change listenervoid removeChangeListener(ChangeListener l)
l
- the change listenerboolean isVisible()
void setVisible(boolean v)
v
- true if the caret should be shown,
and false if the caret should be hiddenboolean isSelectionVisible()
void setSelectionVisible(boolean v)
v
- true if the caret should be shown,
and false if the caret should be hiddenvoid setMagicCaretPosition(Point p)
p
- the Point to use for the saved position. This
can be null to indicate there is no visual location.Point getMagicCaretPosition()
setMagicCaretPosition(java.awt.Point)
void setBlinkRate(int rate)
rate
- the delay in milliseconds >=0. If this is
zero the caret will not blink.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.
dot
- the new position to set the caret tovoid moveDot(int dot)
dot
- the new position to move the caret to >=0 Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.