Spec-Zone.ru › OpenJDK 27

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
public static class BasicTextUI.BasicCaret extends DefaultCaret implements UIResource
Default implementation of the interface Caret.

Nested Class Summary

Nested classes/interfaces declared in class Rectangle2D

Rectangle2D.Double, Rectangle2D.Float
Modifier and Type Class Description
static class  Rectangle2D.Double
The Double class defines a rectangle specified in double coordinates.
static class  Rectangle2D.Float
The Float 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 Type Field Description
static final int ALWAYS_UPDATE
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 changeEvent
The change event for the model.
protected EventListenerList listenerList
The event listener list.
static final int NEVER_UPDATE
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 UPDATE_WHEN_ON_EDT
Indicates that the caret position is to be updated only when document changes are performed on the Event Dispatching Thread.

Fields declared in class Rectangle

height, width, x, y
Modifier and Type Field Description
int height
The height of the Rectangle.
int width
The width of the Rectangle.
int x
The X coordinate of the upper-left corner of the Rectangle.
int y
The Y coordinate of the upper-left corner of the Rectangle.

Fields declared in class Rectangle2D

OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
Modifier and Type Field Description
static final int OUT_BOTTOM
The bitmask that indicates that a point lies below this Rectangle2D.
static final int OUT_LEFT
The bitmask that indicates that a point lies to the left of this Rectangle2D.
static final int OUT_RIGHT
The bitmask that indicates that a point lies to the right of this Rectangle2D.
static final int OUT_TOP
The bitmask that indicates that a point lies above this Rectangle2D.

Constructor Summary

Constructor Description
BasicCaret()
Constructs a BasicCaret.

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 Type Method Description
void addChangeListener(ChangeListener l)
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 damage(Rectangle r)
Damages the area surrounding the caret to cause it to be repainted in a new location.
void deinstall(JTextComponent c)
Called when the UI is being removed from the interface of a JTextComponent.
boolean equals(Object obj)
Compares this object to the specified object.
protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type.
void focusGained(FocusEvent e)
Called when the component containing the caret gains focus.
void focusLost(FocusEvent e)
Called when the component containing the caret loses focus.
int getBlinkRate()
Gets the caret blink rate.
ChangeListener[] getChangeListeners()
Returns an array of all the change listeners registered on this caret.
protected final JTextComponent getComponent()
Gets the text editor component that this caret is bound to.
int getDot()
Fetches the current position of the caret.
Position.Bias getDotBias()
Returns the bias of the caret position.
<T extends EventListener>
T[]
getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListeners upon this caret.
Point getMagicCaretPosition()
Gets the saved caret position.
int getMark()
Fetches the current position of the mark.
Position.Bias getMarkBias()
Returns the bias of the mark.
protected Highlighter.HighlightPainter getSelectionPainter()
Gets the painter for the Highlighter.
int getUpdatePolicy()
Gets the caret movement policy on document updates.
void install(JTextComponent c)
Called when the UI is being installed into the interface of a JTextComponent.
boolean isActive()
Determines if the caret is currently active.
boolean isSelectionVisible()
Checks whether the current selection is visible.
boolean isVisible()
Indicates whether or not the caret is currently visible.
void mouseClicked(MouseEvent e)
Called when the mouse is clicked.
void mouseDragged(MouseEvent e)
Moves the caret position according to the mouse pointer's current location.
void mouseEntered(MouseEvent e)
Called when the mouse enters a region.
void mouseExited(MouseEvent e)
Called when the mouse exits a region.
void mouseMoved(MouseEvent e)
Called when the mouse is moved.
void mousePressed(MouseEvent e)
If button 1 is pressed, this is implemented to request focus on the associated text component, and to set the caret position.
void mouseReleased(MouseEvent e)
Called when the mouse is released.
protected void moveCaret(MouseEvent e)
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 paint(Graphics g)
Renders the caret as a vertical line.
protected void positionCaret(MouseEvent e)
Tries to set the position of the caret from the coordinates of a mouse event, using viewToModel().
void removeChangeListener(ChangeListener l)
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 setMagicCaretPosition(Point p)
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 Type Method Description
void add(int newx, int newy)
Adds a point, specified by the integer arguments newx,newy to the bounds of this Rectangle.
void add(Point pt)
Adds the specified Point to the bounds of this Rectangle.
void add(Rectangle r)
Adds a Rectangle to this Rectangle.
boolean contains(int x, int y)
Checks whether or not this Rectangle contains the point at the specified location (x,y).
boolean contains(int X, int Y, int W, int H)
Checks whether this Rectangle entirely contains the Rectangle at the specified location (X,Y) with the specified dimensions (W,H).
boolean contains(Point p)
Checks whether or not this Rectangle contains the specified Point.
boolean contains(Rectangle r)
Checks whether or not this Rectangle entirely contains the specified Rectangle.
Rectangle2D createIntersection(Rectangle2D r)
Returns a new Rectangle2D object representing the intersection of this Rectangle2D with the specified Rectangle2D.
Rectangle2D createUnion(Rectangle2D r)
Returns a new Rectangle2D object representing the union of this Rectangle2D with the specified Rectangle2D.
Rectangle getBounds()
Gets the bounding Rectangle of this Rectangle.
Rectangle2D getBounds2D()
Returns a high precision and more accurate bounding box of the Shape than the getBounds method.
double getHeight()
Returns the height of the bounding Rectangle in double precision.
Point getLocation()
Returns the location of this Rectangle.
Dimension getSize()
Gets the size of this Rectangle, represented by the returned Dimension.
double getWidth()
Returns the width of the bounding Rectangle in double precision.
double getX()
Returns the X coordinate of the bounding Rectangle in double precision.
double getY()
Returns the Y coordinate of the bounding Rectangle in double precision.
void grow(int h, int v)
Resizes the Rectangle both horizontally and vertically.
boolean inside(int X, int Y)
Deprecated.
As of JDK version 1.1, replaced by contains(int, int).
Rectangle intersection(Rectangle r)
Computes the intersection of this Rectangle with the specified Rectangle.
boolean intersects(Rectangle r)
Determines whether or not this Rectangle and the specified Rectangle intersect.
boolean isEmpty()
Determines whether the RectangularShape is empty.
void move(int x, int y)
Deprecated.
As of JDK version 1.1, replaced by setLocation(int, int).
int outcode(double x, double y)
Determines where the specified coordinates lie with respect to this Rectangle2D.
void reshape(int x, int y, int width, int height)
Deprecated.
As of JDK version 1.1, replaced by setBounds(int, int, int, int).
void resize(int width, int height)
Deprecated.
As of JDK version 1.1, replaced by setSize(int, int).
void setBounds(int x, int y, int width, int height)
Sets the bounding Rectangle of this Rectangle to the specified x, y, width, and height.
void setBounds(Rectangle r)
Sets the bounding Rectangle of this Rectangle to match the specified Rectangle.
void setLocation(int x, int y)
Moves this Rectangle to the specified location.
void setLocation(Point p)
Moves this Rectangle to the specified location.
void setRect(double x, double y, double width, double height)
Sets the bounds of this Rectangle to the integer bounds which encompass the specified x, y, width, and height.
void setSize(int width, int height)
Sets the size of this Rectangle to the specified width and height.
void setSize(Dimension d)
Sets the size of this Rectangle to match the specified Dimension.
String toString()
Returns a String representing this Rectangle and its values.
void translate(int dx, int dy)
Translates this Rectangle the indicated distance, to the right along the X coordinate axis, and downward along the Y coordinate axis.
Rectangle union(Rectangle r)
Computes the union of this Rectangle with the specified Rectangle.

Methods declared in class Rectangle2D

add, add, add, contains, contains, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, setRect, union
Modifier and Type Method Description
void add(double newx, double newy)
Adds a point, specified by the double precision arguments newx and newy, to this Rectangle2D.
void add(Point2D pt)
Adds the Point2D object pt to this Rectangle2D.
void add(Rectangle2D r)
Adds a Rectangle2D object to this Rectangle2D.
boolean contains(double x, double y)
Tests if the specified coordinates are inside the boundary of the Shape, as described by the definition of insideness.
boolean contains(double x, double y, double w, double h)
Tests if the interior of the Shape entirely contains the specified rectangular area.
PathIterator getPathIterator(AffineTransform at)
Returns an iteration object that defines the boundary of this Rectangle2D.
PathIterator getPathIterator(AffineTransform at, double flatness)
Returns an iteration object that defines the boundary of the flattened Rectangle2D.
int hashCode()
Returns the hashcode for this Rectangle2D.
static void intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)
Intersects the pair of specified source Rectangle2D objects and puts the result into the specified destination Rectangle2D object.
boolean intersects(double x, double y, double w, double h)
Tests if the interior of the Shape 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 this Rectangle2D.
boolean intersectsLine(Line2D l)
Tests if the specified line segment intersects the interior of this Rectangle2D.
int outcode(Point2D p)
Determines where the specified Point2D lies with respect to this Rectangle2D.
void setFrame(double x, double y, double w, double h)
Sets the location and size of the outer bounds of this Rectangle2D to the specified rectangular values.
void setRect(Rectangle2D r)
Sets this Rectangle2D to be the same as the specified Rectangle2D.
static void union(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)
Unions the pair of source Rectangle2D objects and puts the result into the specified destination Rectangle2D 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 Type Method Description
Object clone()
Creates a new object of the same class and with the same contents as this object.
boolean contains(Point2D p)
Tests if a specified Point2D is inside the boundary of the Shape, as described by the definition of insideness.
boolean contains(Rectangle2D r)
Tests if the interior of the Shape entirely contains the specified Rectangle2D.
double getCenterX()
Returns the X coordinate of the center of the framing rectangle of the Shape in double precision.
double getCenterY()
Returns the Y coordinate of the center of the framing rectangle of the Shape in double precision.
Rectangle2D getFrame()
Returns the framing Rectangle2D that defines the overall shape of this object.
double getMaxX()
Returns the largest X coordinate of the framing rectangle of the Shape in double precision.
double getMaxY()
Returns the largest Y coordinate of the framing rectangle of the Shape in double precision.
double getMinX()
Returns the smallest X coordinate of the framing rectangle of the Shape in double precision.
double getMinY()
Returns the smallest Y coordinate of the framing rectangle of the Shape in double precision.
boolean intersects(Rectangle2D r)
Tests if the interior of the Shape intersects the interior of a specified Rectangle2D.
void setFrame(Point2D loc, Dimension2D size)
Sets the location and size of the framing rectangle of this Shape to the specified Point2D and Dimension2D, respectively.
void setFrame(Rectangle2D r)
Sets the framing rectangle of this Shape to be the specified Rectangle2D.
void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)
Sets the framing rectangle of this Shape based on the specified center point coordinates and corner point coordinates.
void setFrameFromCenter(Point2D center, Point2D corner)
Sets the framing rectangle of this Shape based on a specified center Point2D and corner Point2D.
void setFrameFromDiagonal(double x1, double y1, double x2, double y2)
Sets the diagonal of the framing rectangle of this Shape based on the two specified coordinates.
void setFrameFromDiagonal(Point2D p1, Point2D p2)
Sets the diagonal of the framing rectangle of this Shape based on two specified Point2D objects.

Methods declared in class Object

finalize, getClass, notify, notifyAll, wait, wait, wait
Modifier and Type Method Description
protected 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 this Object.
final void notify()
Wakes up a single thread that is waiting on this object's monitor.
final void notifyAll()
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 a BasicCaret.

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API