public class ConfigurableCaret
extends javax.swing.text.DefaultCaret
RTextArea. This caret has all of the properties
that javax.swing.text.DefaultCaret does, as well as adding the
following niceties:
setStyle(CaretStyle) method and CaretStyle for
more information.| Constructor and Description |
|---|
ConfigurableCaret()
Creates the caret using
CaretStyle.THICK_VERTICAL_LINE_STYLE. |
ConfigurableCaret(CaretStyle style)
Constructs a new
ConfigurableCaret. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
damage(java.awt.Rectangle r)
Overridden to damage the correct width of the caret, since this caret
can be different sizes.
|
void |
deinstall(javax.swing.text.JTextComponent c)
Called when the UI is being removed from the
interface of a JTextComponent.
|
boolean |
getPasteOnMiddleMouseClick()
Returns whether this caret will paste the contents of the clipboard into
the editor (assuming it is editable) on middle-mouse-button clicks.
|
boolean |
getRoundedSelectionEdges()
Returns whether this caret's selection uses rounded edges.
|
protected javax.swing.text.Highlighter.HighlightPainter |
getSelectionPainter()
Gets the painter for the Highlighter.
|
CaretStyle |
getStyle()
Gets the current style of this caret.
|
protected RTextArea |
getTextArea()
Gets the text editor component that this caret is bound to.
|
void |
install(javax.swing.text.JTextComponent c)
Installs this caret on a text component.
|
boolean |
isAlwaysVisible()
Returns whether this caret is always visible (as opposed to
blinking, or not visible when the editor's window is not focused).
|
void |
mouseClicked(java.awt.event.MouseEvent e)
Called when the mouse is clicked.
|
void |
mousePressed(java.awt.event.MouseEvent e)
Overridden to also focus the text component on right mouse clicks.
|
void |
paint(java.awt.Graphics g)
Paints the cursor.
|
void |
setAlwaysVisible(boolean alwaysVisible)
Toggles whether this caret should always be visible (as opposed to
blinking, or not visible when the editor's window is not focused).
|
void |
setPasteOnMiddleMouseClick(boolean paste)
Sets whether this caret will paste the contents of the clipboard into
the editor (assuming it is editable) on middle-mouse-button clicks.
|
void |
setRoundedSelectionEdges(boolean rounded)
Sets whether this caret's selection should have rounded edges.
|
void |
setSelectionVisible(boolean visible)
Overridden to always render the selection, even when the text component
loses focus.
|
void |
setStyle(CaretStyle style)
Sets the style used when painting the caret.
|
addChangeListener, adjustVisibility, equals, fireStateChanged, focusGained, focusLost, getBlinkRate, getChangeListeners, getComponent, getDot, getDotBias, getListeners, getMagicCaretPosition, getMark, getMarkBias, getUpdatePolicy, isActive, isSelectionVisible, isVisible, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, moveCaret, moveDot, moveDot, positionCaret, removeChangeListener, repaint, setBlinkRate, setDot, setDot, setMagicCaretPosition, setUpdatePolicy, setVisible, toStringadd, add, add, contains, contains, contains, contains, createIntersection, createUnion, getBounds, getBounds2D, getHeight, getLocation, getSize, getWidth, getX, getY, grow, inside, intersection, intersects, isEmpty, move, outcode, reshape, resize, setBounds, setBounds, setLocation, setLocation, setRect, setSize, setSize, translate, unionadd, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, unionclone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonalpublic ConfigurableCaret()
CaretStyle.THICK_VERTICAL_LINE_STYLE.public ConfigurableCaret(CaretStyle style)
ConfigurableCaret.style - The style to use when painting the caret. If this is
invalid, then CaretStyle.THICK_VERTICAL_LINE_STYLE is
used.protected void damage(java.awt.Rectangle r)
damage in class javax.swing.text.DefaultCaretr - The current location of the caret.public void deinstall(javax.swing.text.JTextComponent c)
deinstall in interface javax.swing.text.Caretdeinstall in class javax.swing.text.DefaultCaretc - The text component. If this is not an
RTextArea, an Exception
will be thrown.public boolean getPasteOnMiddleMouseClick()
setPasteOnMiddleMouseClick(boolean)protected RTextArea getTextArea()
RTextArea.public boolean getRoundedSelectionEdges()
setRoundedSelectionEdges(boolean)protected javax.swing.text.Highlighter.HighlightPainter getSelectionPainter()
getSelectionPainter in class javax.swing.text.DefaultCaretpublic CaretStyle getStyle()
setStyle(CaretStyle)public void install(javax.swing.text.JTextComponent c)
install in interface javax.swing.text.Caretinstall in class javax.swing.text.DefaultCaretc - The text component. If this is not an RTextArea,
an Exception will be thrown.public boolean isAlwaysVisible()
setAlwaysVisible(boolean)public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenermouseClicked in class javax.swing.text.DefaultCarete - the mouse eventpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenermousePressed in class javax.swing.text.DefaultCarete - The mouse event.public void paint(java.awt.Graphics g)
paint in interface javax.swing.text.Caretpaint in class javax.swing.text.DefaultCaretg - The graphics context in which to paint.public void setAlwaysVisible(boolean alwaysVisible)
alwaysVisible - Whether this caret should always be visible.isAlwaysVisible()public void setPasteOnMiddleMouseClick(boolean paste)
paste - Whether a paste operation will be performed.getPasteOnMiddleMouseClick()public void setRoundedSelectionEdges(boolean rounded)
rounded - Whether it should have rounded edges.getRoundedSelectionEdges()public void setSelectionVisible(boolean visible)
setSelectionVisible in interface javax.swing.text.CaretsetSelectionVisible in class javax.swing.text.DefaultCaretvisible - Whether the selection should be visible. This parameter
is ignored.public void setStyle(CaretStyle style)
style - The style to use. This should not be null.getStyle()