Class BasicTextUI.BasicCaret
java.lang.Object
java.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.Rectangle
javax.swing.text.DefaultCaret
javax.swing.plaf.basic.BasicTextUI.BasicCaret
- All Implemented Interfaces:
FocusListener, MouseListener, MouseMotionListener, Shape, Serializable, Cloneable, EventListener, UIResource, Caret
- Enclosing class:
BasicTextUI
Default implementation of the interface
Caret
.-
Nested Class Summary
Nested classes/interfaces declared in class Rectangle2D
Rectangle2D.Double, Rectangle2D.Float
Modifier and TypeClassDescriptionstatic class
TheDouble
class defines a rectangle specified in double coordinates.static class
TheFloat
class defines a rectangle specified in float coordinates. -
Field Summary
Fields declared in class DefaultCaret
ALWAYS_UPDATE, changeEvent, listenerList, NEVER_UPDATE, UPDATE_WHEN_ON_EDT
Modifier and TypeFieldDescriptionstatic final int
Indicates that the caret position is to be always updated accordingly to the document changes regardless whether the document updates are performed on the Event Dispatching Thread or not.protected ChangeEvent
The change event for the model.protected EventListenerList
The event listener list.static final int
Indicates that the caret should remain at the same absolute position in the document regardless of any document updates, except when the document length becomes less than the current caret position due to removal.static final int
Indicates that the caret position is to be updated only when document changes are performed on the Event Dispatching Thread.Fields declared in class Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
Modifier and TypeFieldDescriptionstatic final int
The bitmask that indicates that a point lies below thisRectangle2D
.static final int
The bitmask that indicates that a point lies to the left of thisRectangle2D
.static final int
The bitmask that indicates that a point lies to the right of thisRectangle2D
.static final int
The bitmask that indicates that a point lies above thisRectangle2D
. -
Constructor Summary
Constructors -
Method Summary
Methods declared in class DefaultCaret
addChangeListener, adjustVisibility, damage, deinstall, equals, fireStateChanged, focusGained, focusLost, getBlinkRate, getChangeListeners, getComponent, getDot, getDotBias, getListeners, getMagicCaretPosition, getMark, getMarkBias, getSelectionPainter, getUpdatePolicy, install, isActive, isSelectionVisible, isVisible, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, moveCaret, moveDot, moveDot, paint, positionCaret, removeChangeListener, repaint, setBlinkRate, setDot, setDot, setMagicCaretPosition, setSelectionVisible, setUpdatePolicy, setVisible
Modifier and TypeMethodDescriptionvoid
Adds a listener to track whenever the caret position has been changed.protected void
adjustVisibility
(Rectangle nloc) Scrolls the associated view (if necessary) to make the caret visible.protected void
Damages the area surrounding the caret to cause it to be repainted in a new location.void
Called when the UI is being removed from the interface of a JTextComponent.boolean
Compares this object to the specified object.protected void
Notifies all listeners that have registered interest for notification on this event type.void
Called when the component containing the caret gains focus.void
Called when the component containing the caret loses focus.int
Gets the caret blink rate.Returns an array of all the change listeners registered on this caret.protected final JTextComponent
Gets the text editor component that this caret is bound to.int
getDot()
Fetches the current position of the caret.Returns the bias of the caret position.<T extends EventListener>
T[]getListeners
(Class<T> listenerType) Returns an array of all the objects currently registered asFooListener
s upon this caret.Gets the saved caret position.int
getMark()
Fetches the current position of the mark.Returns the bias of the mark.protected Highlighter.HighlightPainter
Gets the painter for the Highlighter.int
Gets the caret movement policy on document updates.void
Called when the UI is being installed into the interface of a JTextComponent.boolean
isActive()
Determines if the caret is currently active.boolean
Checks whether the current selection is visible.boolean
Indicates whether or not the caret is currently visible.void
Called when the mouse is clicked.void
Moves the caret position according to the mouse pointer's current location.void
Called when the mouse enters a region.void
Called when the mouse exits a region.void
Called when the mouse is moved.void
If button 1 is pressed, this is implemented to request focus on the associated text component, and to set the caret position.void
Called when the mouse is released.protected void
Tries to move the position of the caret from the coordinates of a mouse event, using viewToModel().void
moveDot
(int dot) Moves the caret position to the specified position, with a forward bias.void
moveDot
(int dot, Position.Bias dotBias) Moves the caret position to the specified position, with the specified bias.void
Renders the caret as a vertical line.protected void
Tries to set the position of the caret from the coordinates of a mouse event, using viewToModel().void
Removes a listener that was tracking caret position changes.protected final void
repaint()
Cause the caret to be painted.void
setBlinkRate
(int rate) Sets the caret blink rate.void
setDot
(int dot) Sets the caret position and mark to the specified position, with a forward bias.void
setDot
(int dot, Position.Bias dotBias) Sets the caret position and mark to the specified position, with the specified bias.void
Saves the current caret position.void
setSelectionVisible
(boolean vis) Changes the selection visibility.void
setUpdatePolicy
(int policy) Sets the caret movement policy on the document updates.void
setVisible
(boolean e) Sets the caret visibility, and repaints the caret.Methods declared in class 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, toString, translate, union
Modifier and TypeMethodDescriptionvoid
add
(int newx, int newy) Adds a point, specified by the integer argumentsnewx,newy
to the bounds of thisRectangle
.void
Adds the specifiedPoint
to the bounds of thisRectangle
.void
Adds aRectangle
to thisRectangle
.boolean
contains
(int x, int y) Checks whether or not thisRectangle
contains the point at the specified location(x,y)
.boolean
contains
(int X, int Y, int W, int H) Checks whether thisRectangle
entirely contains theRectangle
at the specified location(X,Y)
with the specified dimensions(W,H)
.boolean
Checks whether or not thisRectangle
contains the specifiedPoint
.boolean
Checks whether or not thisRectangle
entirely contains the specifiedRectangle
.Returns a newRectangle2D
object representing the intersection of thisRectangle2D
with the specifiedRectangle2D
.Returns a newRectangle2D
object representing the union of thisRectangle2D
with the specifiedRectangle2D
.Gets the boundingRectangle
of thisRectangle
.Returns a high precision and more accurate bounding box of theShape
than thegetBounds
method.double
Returns the height of the boundingRectangle
indouble
precision.Returns the location of thisRectangle
.getSize()
Gets the size of thisRectangle
, represented by the returnedDimension
.double
getWidth()
Returns the width of the boundingRectangle
indouble
precision.double
getX()
Returns the X coordinate of the boundingRectangle
indouble
precision.double
getY()
Returns the Y coordinate of the boundingRectangle
indouble
precision.void
grow
(int h, int v) Resizes theRectangle
both horizontally and vertically.boolean
inside
(int X, int Y) Deprecated.Computes the intersection of thisRectangle
with the specifiedRectangle
.boolean
Determines whether or not thisRectangle
and the specifiedRectangle
intersect.boolean
isEmpty()
Determines whether theRectangularShape
is empty.void
move
(int x, int y) Deprecated.As of JDK version 1.1, replaced bysetLocation(int, int)
.int
outcode
(double x, double y) Determines where the specified coordinates lie with respect to thisRectangle2D
.void
reshape
(int x, int y, int width, int height) Deprecated.As of JDK version 1.1, replaced bysetBounds(int, int, int, int)
.void
resize
(int width, int height) Deprecated.As of JDK version 1.1, replaced bysetSize(int, int)
.void
setBounds
(int x, int y, int width, int height) Sets the boundingRectangle
of thisRectangle
to the specifiedx
,y
,width
, andheight
.void
Sets the boundingRectangle
of thisRectangle
to match the specifiedRectangle
.void
setLocation
(int x, int y) Moves thisRectangle
to the specified location.void
setLocation
(Point p) Moves thisRectangle
to the specified location.void
setRect
(double x, double y, double width, double height) Sets the bounds of thisRectangle
to the integer bounds which encompass the specifiedx
,y
,width
, andheight
.void
setSize
(int width, int height) Sets the size of thisRectangle
to the specified width and height.void
Sets the size of thisRectangle
to match the specifiedDimension
.toString()
Returns aString
representing thisRectangle
and its values.void
translate
(int dx, int dy) Translates thisRectangle
the indicated distance, to the right along the X coordinate axis, and downward along the Y coordinate axis.Computes the union of thisRectangle
with the specifiedRectangle
.Methods declared in class Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
Modifier and TypeMethodDescriptionvoid
add
(double newx, double newy) Adds a point, specified by the double precision argumentsnewx
andnewy
, to thisRectangle2D
.void
Adds thePoint2D
objectpt
to thisRectangle2D
.void
add
(Rectangle2D r) Adds aRectangle2D
object to thisRectangle2D
.boolean
contains
(double x, double y) Tests if the specified coordinates are inside the boundary of theShape
, as described by the definition of insideness.boolean
contains
(double x, double y, double w, double h) Tests if the interior of theShape
entirely contains the specified rectangular area.Returns an iteration object that defines the boundary of thisRectangle2D
.getPathIterator
(AffineTransform at, double flatness) Returns an iteration object that defines the boundary of the flattenedRectangle2D
.int
hashCode()
Returns the hashcode for thisRectangle2D
.static void
intersect
(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) Intersects the pair of specified sourceRectangle2D
objects and puts the result into the specified destinationRectangle2D
object.boolean
intersects
(double x, double y, double w, double h) Tests if the interior of theShape
intersects the interior of a specified rectangular area.boolean
intersectsLine
(double x1, double y1, double x2, double y2) Tests if the specified line segment intersects the interior of thisRectangle2D
.boolean
Tests if the specified line segment intersects the interior of thisRectangle2D
.int
Determines where the specifiedPoint2D
lies with respect to thisRectangle2D
.void
setFrame
(double x, double y, double w, double h) Sets the location and size of the outer bounds of thisRectangle2D
to the specified rectangular values.void
Sets thisRectangle2D
to be the same as the specifiedRectangle2D
.static void
union
(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest) Unions the pair of sourceRectangle2D
objects and puts the result into the specified destinationRectangle2D
object.Methods declared in class RectangularShape
clone, contains, contains, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
Modifier and TypeMethodDescriptionclone()
Creates a new object of the same class and with the same contents as this object.boolean
Tests if a specifiedPoint2D
is inside the boundary of theShape
, as described by the definition of insideness.boolean
Tests if the interior of theShape
entirely contains the specifiedRectangle2D
.double
Returns the X coordinate of the center of the framing rectangle of theShape
indouble
precision.double
Returns the Y coordinate of the center of the framing rectangle of theShape
indouble
precision.getFrame()
Returns the framingRectangle2D
that defines the overall shape of this object.double
getMaxX()
Returns the largest X coordinate of the framing rectangle of theShape
indouble
precision.double
getMaxY()
Returns the largest Y coordinate of the framing rectangle of theShape
indouble
precision.double
getMinX()
Returns the smallest X coordinate of the framing rectangle of theShape
indouble
precision.double
getMinY()
Returns the smallest Y coordinate of the framing rectangle of theShape
indouble
precision.boolean
Tests if the interior of theShape
intersects the interior of a specifiedRectangle2D
.void
setFrame
(Point2D loc, Dimension2D size) Sets the location and size of the framing rectangle of thisShape
to the specifiedPoint2D
andDimension2D
, respectively.void
Sets the framing rectangle of thisShape
to be the specifiedRectangle2D
.void
setFrameFromCenter
(double centerX, double centerY, double cornerX, double cornerY) Sets the framing rectangle of thisShape
based on the specified center point coordinates and corner point coordinates.void
setFrameFromCenter
(Point2D center, Point2D corner) Sets the framing rectangle of thisShape
based on a specified centerPoint2D
and cornerPoint2D
.void
setFrameFromDiagonal
(double x1, double y1, double x2, double y2) Sets the diagonal of the framing rectangle of thisShape
based on the two specified coordinates.void
setFrameFromDiagonal
(Point2D p1, Point2D p2) Sets the diagonal of the framing rectangle of thisShape
based on two specifiedPoint2D
objects.Methods declared in class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
BasicCaret
public BasicCaret()Constructs aBasicCaret
.
-
contains(int, int)
.