Package com.formdev.flatlaf.ui
Class FlatCaret
- java.lang.Object
-
- java.awt.geom.RectangularShape
-
- java.awt.geom.Rectangle2D
-
- java.awt.Rectangle
-
- javax.swing.text.DefaultCaret
-
- com.formdev.flatlaf.ui.FlatCaret
-
- All Implemented Interfaces:
FocusListener
,MouseListener
,MouseMotionListener
,Shape
,Serializable
,Cloneable
,EventListener
,UIResource
,Caret
public class FlatCaret extends DefaultCaret implements UIResource
Caret that can select all text on focus gained. Also fixes Swing's double-click-and-drag behavior so that dragging after a double-click extends selection by whole words.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
-
-
Field Summary
-
Fields inherited from class javax.swing.text.DefaultCaret
ALWAYS_UPDATE, changeEvent, listenerList, NEVER_UPDATE, UPDATE_WHEN_ON_EDT
-
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adjustVisibility(Rectangle nloc)
void
deinstall(JTextComponent c)
void
focusGained(FocusEvent e)
void
focusLost(FocusEvent e)
void
install(JTextComponent c)
void
mouseDragged(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
scrollCaretToVisible()
protected void
selectAllOnFocusGained()
-
Methods inherited from class javax.swing.text.DefaultCaret
addChangeListener, damage, equals, fireStateChanged, getBlinkRate, getChangeListeners, getComponent, getDot, getDotBias, getListeners, getMagicCaretPosition, getMark, getMarkBias, getSelectionPainter, getUpdatePolicy, isActive, isSelectionVisible, isVisible, mouseClicked, mouseEntered, mouseExited, mouseMoved, moveCaret, moveDot, moveDot, paint, positionCaret, removeChangeListener, repaint, setBlinkRate, setDot, setDot, setMagicCaretPosition, setSelectionVisible, setUpdatePolicy, setVisible, toString
-
Methods inherited from class java.awt.Rectangle
add, 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, union
-
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
-
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getPathIterator, getPathIterator, intersects, intersects
-
-
-
-
Constructor Detail
-
FlatCaret
public FlatCaret(String selectAllOnFocusPolicy, boolean selectAllOnMouseClick)
-
-
Method Detail
-
install
public void install(JTextComponent c)
- Specified by:
install
in interfaceCaret
- Overrides:
install
in classDefaultCaret
-
deinstall
public void deinstall(JTextComponent c)
- Specified by:
deinstall
in interfaceCaret
- Overrides:
deinstall
in classDefaultCaret
-
adjustVisibility
protected void adjustVisibility(Rectangle nloc)
- Overrides:
adjustVisibility
in classDefaultCaret
-
focusGained
public void focusGained(FocusEvent e)
- Specified by:
focusGained
in interfaceFocusListener
- Overrides:
focusGained
in classDefaultCaret
-
focusLost
public void focusLost(FocusEvent e)
- Specified by:
focusLost
in interfaceFocusListener
- Overrides:
focusLost
in classDefaultCaret
-
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classDefaultCaret
-
mouseReleased
public void mouseReleased(MouseEvent e)
- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classDefaultCaret
-
mouseDragged
public void mouseDragged(MouseEvent e)
- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classDefaultCaret
-
selectAllOnFocusGained
protected void selectAllOnFocusGained()
-
scrollCaretToVisible
public void scrollCaretToVisible()
- Since:
- 1.4
-
-