javax.swing.text
Class DefaultCaret

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.geom.RectangularShape sample code for java.awt.geom.RectangularShape definition code for java.awt.geom.RectangularShape 
      extended by java.awt.geom.Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D 
          extended by java.awt.Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle 
              extended by javax.swing.text.DefaultCaret
All Implemented Interfaces:
FocusListener sample code for java.awt.event.FocusListener definition code for java.awt.event.FocusListener , MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener , MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener , Shape sample code for java.awt.Shape definition code for java.awt.Shape , Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , EventListener sample code for java.util.EventListener definition code for java.util.EventListener , Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Direct Known Subclasses:
BasicTextUI.BasicCaret sample code for javax.swing.plaf.basic.BasicTextUI.BasicCaret definition code for javax.swing.plaf.basic.BasicTextUI.BasicCaret

public class DefaultCaret
extends Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle
implements Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret , FocusListener sample code for java.awt.event.FocusListener definition code for java.awt.event.FocusListener , MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener , MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener

A default implementation of Caret. The caret is rendered as a vertical line in the color specified by the CaretColor property of the associated JTextComponent. It can blink at the rate specified by the BlinkRate property.

This implementation expects two sources of asynchronous notification. The timer thread fires asynchronously, and causes the caret to simply repaint the most recent bounding box. The caret also tracks change as the document is modified. Typically this will happen on the event dispatch thread as a result of some mouse or keyboard event. The caret behavior on both synchronous and asynchronous documents updates is controlled by UpdatePolicy property. The repaint of the new caret location will occur on the event thread in any case, as calls to modelToView are only safe on the event thread.

The caret acts as a mouse and focus listener on the text component it has been installed in, and defines the caret semantics based upon those events. The listener methods can be reimplemented to change the semantics. By default, the first mouse button will be used to set focus and caret position. Dragging the mouse pointer with the first mouse button will sweep out a selection that is contiguous in the model. If the associated text component is editable, the caret will become visible when focus is gained, and invisible when focus is lost.

The Highlighter bound to the associated text component is used to render the selection by default. Selection appearance can be customized by supplying a painter to use for the highlights. By default a painter is used that will render a solid color as specified in the associated text component in the SelectionColor property. This can easily be changed by reimplementing the getSelectionHighlighter method.

A customized caret appearance can be achieved by reimplementing the paint method. If the paint method is changed, the damage method should also be reimplemented to cause a repaint for the area needed to render the caret. The caret extends the Rectangle class which is used to hold the bounding box for where the caret was last rendered. This enables the caret to repaint in a thread-safe manner when the caret moves without making a call to modelToView which is unstable between model updates and view repair (i.e. the order of delivery to DocumentListeners is not guaranteed).

The magic caret position is set to null when the caret position changes. A timer is used to determine the new location (after the caret change). When the timer fires, if the magic caret position is still null it is reset to the current caret position. Any actions that change the caret position and want the magic caret position to remain the same, must remember the magic caret position, change the cursor, and then set the magic caret position to its original value. This has the benefit that only actions that want the magic caret position to persist (such as open/down) need to know about it.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

See Also:
Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret , Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D
Rectangle2D.Double sample code for java.awt.geom.Rectangle2D.Double definition code for java.awt.geom.Rectangle2D.Double , Rectangle2D.Float sample code for java.awt.geom.Rectangle2D.Float definition code for java.awt.geom.Rectangle2D.Float
 
Field Summary
static int ALWAYS_UPDATE sample code for javax.swing.text.DefaultCaret.ALWAYS_UPDATE definition code for javax.swing.text.DefaultCaret.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 sample code for javax.swing.event.ChangeEvent definition code for javax.swing.event.ChangeEvent changeEvent sample code for javax.swing.text.DefaultCaret.changeEvent definition code for javax.swing.text.DefaultCaret.changeEvent
          The change event for the model.
protected  EventListenerList sample code for javax.swing.event.EventListenerList definition code for javax.swing.event.EventListenerList listenerList sample code for javax.swing.text.DefaultCaret.listenerList definition code for javax.swing.text.DefaultCaret.listenerList
          The event listener list.
static int NEVER_UPDATE sample code for javax.swing.text.DefaultCaret.NEVER_UPDATE definition code for javax.swing.text.DefaultCaret.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 int UPDATE_WHEN_ON_EDT sample code for javax.swing.text.DefaultCaret.UPDATE_WHEN_ON_EDT definition code for javax.swing.text.DefaultCaret.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 inherited from class java.awt.Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle
height sample code for java.awt.Rectangle.height definition code for java.awt.Rectangle.height , width sample code for java.awt.Rectangle.width definition code for java.awt.Rectangle.width , x sample code for java.awt.Rectangle.x definition code for java.awt.Rectangle.x , y sample code for java.awt.Rectangle.y definition code for java.awt.Rectangle.y
 
Fields inherited from class java.awt.geom.Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D
OUT_BOTTOM sample code for java.awt.geom.Rectangle2D.OUT_BOTTOM definition code for java.awt.geom.Rectangle2D.OUT_BOTTOM , OUT_LEFT sample code for java.awt.geom.Rectangle2D.OUT_LEFT definition code for java.awt.geom.Rectangle2D.OUT_LEFT , OUT_RIGHT sample code for java.awt.geom.Rectangle2D.OUT_RIGHT definition code for java.awt.geom.Rectangle2D.OUT_RIGHT , OUT_TOP sample code for java.awt.geom.Rectangle2D.OUT_TOP definition code for java.awt.geom.Rectangle2D.OUT_TOP
 
Constructor Summary
DefaultCaret sample code for javax.swing.text.DefaultCaret.DefaultCaret() definition code for javax.swing.text.DefaultCaret.DefaultCaret() ()
          Constructs a default caret.
 
Method Summary
 void addChangeListener sample code for javax.swing.text.DefaultCaret.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.DefaultCaret.addChangeListener(javax.swing.event.ChangeListener) (ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
          Adds a listener to track whenever the caret position has been changed.
protected  void adjustVisibility sample code for javax.swing.text.DefaultCaret.adjustVisibility(java.awt.Rectangle) definition code for javax.swing.text.DefaultCaret.adjustVisibility(java.awt.Rectangle) (Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  nloc)
          Scrolls the associated view (if necessary) to make the caret visible.
protected  void damage sample code for javax.swing.text.DefaultCaret.damage(java.awt.Rectangle) definition code for javax.swing.text.DefaultCaret.damage(java.awt.Rectangle) (Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  r)
          Damages the area surrounding the caret to cause it to be repainted in a new location.
 void deinstall sample code for javax.swing.text.DefaultCaret.deinstall(javax.swing.text.JTextComponent) definition code for javax.swing.text.DefaultCaret.deinstall(javax.swing.text.JTextComponent) (JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  c)
          Called when the UI is being removed from the interface of a JTextComponent.
 boolean equals sample code for javax.swing.text.DefaultCaret.equals(java.lang.Object) definition code for javax.swing.text.DefaultCaret.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Compares this object to the specified object.
protected  void fireStateChanged sample code for javax.swing.text.DefaultCaret.fireStateChanged() definition code for javax.swing.text.DefaultCaret.fireStateChanged() ()
          Notifies all listeners that have registered interest for notification on this event type.
 void focusGained sample code for javax.swing.text.DefaultCaret.focusGained(java.awt.event.FocusEvent) definition code for javax.swing.text.DefaultCaret.focusGained(java.awt.event.FocusEvent) (FocusEvent sample code for java.awt.event.FocusEvent definition code for java.awt.event.FocusEvent  e)
          Called when the component containing the caret gains focus.
 void focusLost sample code for javax.swing.text.DefaultCaret.focusLost(java.awt.event.FocusEvent) definition code for javax.swing.text.DefaultCaret.focusLost(java.awt.event.FocusEvent) (FocusEvent sample code for java.awt.event.FocusEvent definition code for java.awt.event.FocusEvent  e)
          Called when the component containing the caret loses focus.
 int getBlinkRate sample code for javax.swing.text.DefaultCaret.getBlinkRate() definition code for javax.swing.text.DefaultCaret.getBlinkRate() ()
          Gets the caret blink rate.
 ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener [] getChangeListeners sample code for javax.swing.text.DefaultCaret.getChangeListeners() definition code for javax.swing.text.DefaultCaret.getChangeListeners() ()
          Returns an array of all the change listeners registered on this caret.
protected  JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent getComponent sample code for javax.swing.text.DefaultCaret.getComponent() definition code for javax.swing.text.DefaultCaret.getComponent() ()
          Gets the text editor component that this caret is is bound to.
 int getDot sample code for javax.swing.text.DefaultCaret.getDot() definition code for javax.swing.text.DefaultCaret.getDot() ()
          Fetches the current position of the caret.
<T extends EventListener sample code for java.util.EventListener definition code for java.util.EventListener >
T[]
getListeners sample code for javax.swing.text.DefaultCaret.getListeners(java.lang.Class) definition code for javax.swing.text.DefaultCaret.getListeners(java.lang.Class) (Class sample code for java.lang.Class definition code for java.lang.Class <T> listenerType)
          Returns an array of all the objects currently registered as FooListeners upon this caret.
 Point sample code for java.awt.Point definition code for java.awt.Point getMagicCaretPosition sample code for javax.swing.text.DefaultCaret.getMagicCaretPosition() definition code for javax.swing.text.DefaultCaret.getMagicCaretPosition() ()
          Gets the saved caret position.
 int getMark sample code for javax.swing.text.DefaultCaret.getMark() definition code for javax.swing.text.DefaultCaret.getMark() ()
          Fetches the current position of the mark.
protected  Highlighter.HighlightPainter sample code for javax.swing.text.Highlighter.HighlightPainter definition code for javax.swing.text.Highlighter.HighlightPainter getSelectionPainter sample code for javax.swing.text.DefaultCaret.getSelectionPainter() definition code for javax.swing.text.DefaultCaret.getSelectionPainter() ()
          Gets the painter for the Highlighter.
 int getUpdatePolicy sample code for javax.swing.text.DefaultCaret.getUpdatePolicy() definition code for javax.swing.text.DefaultCaret.getUpdatePolicy() ()
          Gets the caret movement policy on document updates.
 void install sample code for javax.swing.text.DefaultCaret.install(javax.swing.text.JTextComponent) definition code for javax.swing.text.DefaultCaret.install(javax.swing.text.JTextComponent) (JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  c)
          Called when the UI is being installed into the interface of a JTextComponent.
 boolean isActive sample code for javax.swing.text.DefaultCaret.isActive() definition code for javax.swing.text.DefaultCaret.isActive() ()
          Determines if the caret is currently active.
 boolean isSelectionVisible sample code for javax.swing.text.DefaultCaret.isSelectionVisible() definition code for javax.swing.text.DefaultCaret.isSelectionVisible() ()
          Checks whether the current selection is visible.
 boolean isVisible sample code for javax.swing.text.DefaultCaret.isVisible() definition code for javax.swing.text.DefaultCaret.isVisible() ()
          Indicates whether or not the caret is currently visible.
 void mouseClicked sample code for javax.swing.text.DefaultCaret.mouseClicked(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseClicked(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Called when the mouse is clicked.
 void mouseDragged sample code for javax.swing.text.DefaultCaret.mouseDragged(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseDragged(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Moves the caret position according to the mouse pointer's current location.
 void mouseEntered sample code for javax.swing.text.DefaultCaret.mouseEntered(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseEntered(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Called when the mouse enters a region.
 void mouseExited sample code for javax.swing.text.DefaultCaret.mouseExited(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseExited(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Called when the mouse exits a region.
 void mouseMoved sample code for javax.swing.text.DefaultCaret.mouseMoved(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseMoved(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Called when the mouse is moved.
 void mousePressed sample code for javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.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 sample code for javax.swing.text.DefaultCaret.mouseReleased(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseReleased(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Called when the mouse is released.
protected  void moveCaret sample code for javax.swing.text.DefaultCaret.moveCaret(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.moveCaret(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Tries to move the position of the caret from the coordinates of a mouse event, using viewToModel().
 void moveDot sample code for javax.swing.text.DefaultCaret.moveDot(int) definition code for javax.swing.text.DefaultCaret.moveDot(int) (int dot)
          Moves the caret position to some other position.
 void paint sample code for javax.swing.text.DefaultCaret.paint(java.awt.Graphics) definition code for javax.swing.text.DefaultCaret.paint(java.awt.Graphics) (Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g)
          Renders the caret as a vertical line.
protected  void positionCaret sample code for javax.swing.text.DefaultCaret.positionCaret(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.positionCaret(java.awt.event.MouseEvent) (MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
          Tries to set the position of the caret from the coordinates of a mouse event, using viewToModel().
 void removeChangeListener sample code for javax.swing.text.DefaultCaret.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.DefaultCaret.removeChangeListener(javax.swing.event.ChangeListener) (ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
          Removes a listener that was tracking caret position changes.
protected  void repaint sample code for javax.swing.text.DefaultCaret.repaint() definition code for javax.swing.text.DefaultCaret.repaint() ()
          Cause the caret to be painted.
 void setBlinkRate sample code for javax.swing.text.DefaultCaret.setBlinkRate(int) definition code for javax.swing.text.DefaultCaret.setBlinkRate(int) (int rate)
          Sets the caret blink rate.
 void setDot sample code for javax.swing.text.DefaultCaret.setDot(int) definition code for javax.swing.text.DefaultCaret.setDot(int) (int dot)
          Sets the caret position and mark to some position.
 void setMagicCaretPosition sample code for javax.swing.text.DefaultCaret.setMagicCaretPosition(java.awt.Point) definition code for javax.swing.text.DefaultCaret.setMagicCaretPosition(java.awt.Point) (Point sample code for java.awt.Point definition code for java.awt.Point  p)
          Saves the current caret position.
 void setSelectionVisible sample code for javax.swing.text.DefaultCaret.setSelectionVisible(boolean) definition code for javax.swing.text.DefaultCaret.setSelectionVisible(boolean) (boolean vis)
          Changes the selection visibility.
 void setUpdatePolicy sample code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) definition code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) (int policy)
          Sets the caret movement policy on the document updates.
 void setVisible sample code for javax.swing.text.DefaultCaret.setVisible(boolean) definition code for javax.swing.text.DefaultCaret.setVisible(boolean) (boolean e)
          Sets the caret visibility, and repaints the caret.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.swing.text.DefaultCaret.toString() definition code for javax.swing.text.DefaultCaret.toString() ()
          Returns a String representing this Rectangle and its values.
 
Methods inherited from class java.awt.Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle
add sample code for java.awt.Rectangle.add(int, int) definition code for java.awt.Rectangle.add(int, int) , add sample code for java.awt.Rectangle.add(java.awt.Point) definition code for java.awt.Rectangle.add(java.awt.Point) , add sample code for java.awt.Rectangle.add(java.awt.Rectangle) definition code for java.awt.Rectangle.add(java.awt.Rectangle) , contains sample code for java.awt.Rectangle.contains(int, int) definition code for java.awt.Rectangle.contains(int, int) , contains sample code for java.awt.Rectangle.contains(int, int, int, int) definition code for java.awt.Rectangle.contains(int, int, int, int) , contains sample code for java.awt.Rectangle.contains(java.awt.Point) definition code for java.awt.Rectangle.contains(java.awt.Point) , contains sample code for java.awt.Rectangle.contains(java.awt.Rectangle) definition code for java.awt.Rectangle.contains(java.awt.Rectangle) , createIntersection sample code for java.awt.Rectangle.createIntersection(java.awt.geom.Rectangle2D) definition code for java.awt.Rectangle.createIntersection(java.awt.geom.Rectangle2D) , createUnion sample code for java.awt.Rectangle.createUnion(java.awt.geom.Rectangle2D) definition code for java.awt.Rectangle.createUnion(java.awt.geom.Rectangle2D) , getBounds sample code for java.awt.Rectangle.getBounds() definition code for java.awt.Rectangle.getBounds() , getBounds2D sample code for java.awt.Rectangle.getBounds2D() definition code for java.awt.Rectangle.getBounds2D() , getHeight sample code for java.awt.Rectangle.getHeight() definition code for java.awt.Rectangle.getHeight() , getLocation sample code for java.awt.Rectangle.getLocation() definition code for java.awt.Rectangle.getLocation() , getSize sample code for java.awt.Rectangle.getSize() definition code for java.awt.Rectangle.getSize() , getWidth sample code for java.awt.Rectangle.getWidth() definition code for java.awt.Rectangle.getWidth() , getX sample code for java.awt.Rectangle.getX() definition code for java.awt.Rectangle.getX() , getY sample code for java.awt.Rectangle.getY() definition code for java.awt.Rectangle.getY() , grow sample code for java.awt.Rectangle.grow(int, int) definition code for java.awt.Rectangle.grow(int, int) , inside sample code for java.awt.Rectangle.inside(int, int) definition code for java.awt.Rectangle.inside(int, int) , intersection sample code for java.awt.Rectangle.intersection(java.awt.Rectangle) definition code for java.awt.Rectangle.intersection(java.awt.Rectangle) , intersects sample code for java.awt.Rectangle.intersects(java.awt.Rectangle) definition code for java.awt.Rectangle.intersects(java.awt.Rectangle) , isEmpty sample code for java.awt.Rectangle.isEmpty() definition code for java.awt.Rectangle.isEmpty() , move sample code for java.awt.Rectangle.move(int, int) definition code for java.awt.Rectangle.move(int, int) , outcode sample code for java.awt.Rectangle.outcode(double, double) definition code for java.awt.Rectangle.outcode(double, double) , reshape sample code for java.awt.Rectangle.reshape(int, int, int, int) definition code for java.awt.Rectangle.reshape(int, int, int, int) , resize sample code for java.awt.Rectangle.resize(int, int) definition code for java.awt.Rectangle.resize(int, int) , setBounds sample code for java.awt.Rectangle.setBounds(int, int, int, int) definition code for java.awt.Rectangle.setBounds(int, int, int, int) , setBounds sample code for java.awt.Rectangle.setBounds(java.awt.Rectangle) definition code for java.awt.Rectangle.setBounds(java.awt.Rectangle) , setLocation sample code for java.awt.Rectangle.setLocation(int, int) definition code for java.awt.Rectangle.setLocation(int, int) , setLocation sample code for java.awt.Rectangle.setLocation(java.awt.Point) definition code for java.awt.Rectangle.setLocation(java.awt.Point) , setRect sample code for java.awt.Rectangle.setRect(double, double, double, double) definition code for java.awt.Rectangle.setRect(double, double, double, double) , setSize sample code for java.awt.Rectangle.setSize(java.awt.Dimension) definition code for java.awt.Rectangle.setSize(java.awt.Dimension) , setSize sample code for java.awt.Rectangle.setSize(int, int) definition code for java.awt.Rectangle.setSize(int, int) , translate sample code for java.awt.Rectangle.translate(int, int) definition code for java.awt.Rectangle.translate(int, int) , union sample code for java.awt.Rectangle.union(java.awt.Rectangle) definition code for java.awt.Rectangle.union(java.awt.Rectangle)
 
Methods inherited from class java.awt.geom.Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D
add sample code for java.awt.geom.Rectangle2D.add(double, double) definition code for java.awt.geom.Rectangle2D.add(double, double) , add sample code for java.awt.geom.Rectangle2D.add(java.awt.geom.Point2D) definition code for java.awt.geom.Rectangle2D.add(java.awt.geom.Point2D) , add sample code for java.awt.geom.Rectangle2D.add(java.awt.geom.Rectangle2D) definition code for java.awt.geom.Rectangle2D.add(java.awt.geom.Rectangle2D) , contains sample code for java.awt.geom.Rectangle2D.contains(double, double) definition code for java.awt.geom.Rectangle2D.contains(double, double) , contains sample code for java.awt.geom.Rectangle2D.contains(double, double, double, double) definition code for java.awt.geom.Rectangle2D.contains(double, double, double, double) , getPathIterator sample code for java.awt.geom.Rectangle2D.getPathIterator(java.awt.geom.AffineTransform) definition code for java.awt.geom.Rectangle2D.getPathIterator(java.awt.geom.AffineTransform) , getPathIterator sample code for java.awt.geom.Rectangle2D.getPathIterator(java.awt.geom.AffineTransform, double) definition code for java.awt.geom.Rectangle2D.getPathIterator(java.awt.geom.AffineTransform, double) , hashCode sample code for java.awt.geom.Rectangle2D.hashCode() definition code for java.awt.geom.Rectangle2D.hashCode() , intersect sample code for java.awt.geom.Rectangle2D.intersect(java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D) definition code for java.awt.geom.Rectangle2D.intersect(java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D) , intersects sample code for java.awt.geom.Rectangle2D.intersects(double, double, double, double) definition code for java.awt.geom.Rectangle2D.intersects(double, double, double, double) , intersectsLine sample code for java.awt.geom.Rectangle2D.intersectsLine(double, double, double, double) definition code for java.awt.geom.Rectangle2D.intersectsLine(double, double, double, double) , intersectsLine sample code for java.awt.geom.Rectangle2D.intersectsLine(java.awt.geom.Line2D) definition code for java.awt.geom.Rectangle2D.intersectsLine(java.awt.geom.Line2D) , outcode sample code for java.awt.geom.Rectangle2D.outcode(java.awt.geom.Point2D) definition code for java.awt.geom.Rectangle2D.outcode(java.awt.geom.Point2D) , setFrame sample code for java.awt.geom.Rectangle2D.setFrame(double, double, double, double) definition code for java.awt.geom.Rectangle2D.setFrame(double, double, double, double) , setRect sample code for java.awt.geom.Rectangle2D.setRect(java.awt.geom.Rectangle2D) definition code for java.awt.geom.Rectangle2D.setRect(java.awt.geom.Rectangle2D) , union sample code for java.awt.geom.Rectangle2D.union(java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D) definition code for java.awt.geom.Rectangle2D.union(java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D, java.awt.geom.Rectangle2D)
 
Methods inherited from class java.awt.geom.RectangularShape sample code for java.awt.geom.RectangularShape definition code for java.awt.geom.RectangularShape
clone sample code for java.awt.geom.RectangularShape.clone() definition code for java.awt.geom.RectangularShape.clone() , contains sample code for java.awt.geom.RectangularShape.contains(java.awt.geom.Point2D) definition code for java.awt.geom.RectangularShape.contains(java.awt.geom.Point2D) , contains sample code for java.awt.geom.RectangularShape.contains(java.awt.geom.Rectangle2D) definition code for java.awt.geom.RectangularShape.contains(java.awt.geom.Rectangle2D) , getCenterX sample code for java.awt.geom.RectangularShape.getCenterX() definition code for java.awt.geom.RectangularShape.getCenterX() , getCenterY sample code for java.awt.geom.RectangularShape.getCenterY() definition code for java.awt.geom.RectangularShape.getCenterY() , getFrame sample code for java.awt.geom.RectangularShape.getFrame() definition code for java.awt.geom.RectangularShape.getFrame() , getMaxX sample code for java.awt.geom.RectangularShape.getMaxX() definition code for java.awt.geom.RectangularShape.getMaxX() , getMaxY sample code for java.awt.geom.RectangularShape.getMaxY() definition code for java.awt.geom.RectangularShape.getMaxY() , getMinX sample code for java.awt.geom.RectangularShape.getMinX() definition code for java.awt.geom.RectangularShape.getMinX() , getMinY sample code for java.awt.geom.RectangularShape.getMinY() definition code for java.awt.geom.RectangularShape.getMinY() , intersects sample code for java.awt.geom.RectangularShape.intersects(java.awt.geom.Rectangle2D) definition code for java.awt.geom.RectangularShape.intersects(java.awt.geom.Rectangle2D) , setFrame sample code for java.awt.geom.RectangularShape.setFrame(java.awt.geom.Point2D, java.awt.geom.Dimension2D) definition code for java.awt.geom.RectangularShape.setFrame(java.awt.geom.Point2D, java.awt.geom.Dimension2D) , setFrame sample code for java.awt.geom.RectangularShape.setFrame(java.awt.geom.Rectangle2D) definition code for java.awt.geom.RectangularShape.setFrame(java.awt.geom.Rectangle2D) , setFrameFromCenter sample code for java.awt.geom.RectangularShape.setFrameFromCenter(double, double, double, double) definition code for java.awt.geom.RectangularShape.setFrameFromCenter(double, double, double, double) , setFrameFromCenter sample code for java.awt.geom.RectangularShape.setFrameFromCenter(java.awt.geom.Point2D, java.awt.geom.Point2D) definition code for java.awt.geom.RectangularShape.setFrameFromCenter(java.awt.geom.Point2D, java.awt.geom.Point2D) , setFrameFromDiagonal sample code for java.awt.geom.RectangularShape.setFrameFromDiagonal(double, double, double, double) definition code for java.awt.geom.RectangularShape.setFrameFromDiagonal(double, double, double, double) , setFrameFromDiagonal sample code for java.awt.geom.RectangularShape.setFrameFromDiagonal(java.awt.geom.Point2D, java.awt.geom.Point2D) definition code for java.awt.geom.RectangularShape.setFrameFromDiagonal(java.awt.geom.Point2D, java.awt.geom.Point2D)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 
Methods inherited from interface java.awt.Shape sample code for java.awt.Shape definition code for java.awt.Shape
contains sample code for java.awt.Shape.contains(double, double) definition code for java.awt.Shape.contains(double, double) , contains sample code for java.awt.Shape.contains(double, double, double, double) definition code for java.awt.Shape.contains(double, double, double, double) , contains sample code for java.awt.Shape.contains(java.awt.geom.Point2D) definition code for java.awt.Shape.contains(java.awt.geom.Point2D) , contains sample code for java.awt.Shape.contains(java.awt.geom.Rectangle2D) definition code for java.awt.Shape.contains(java.awt.geom.Rectangle2D) , getPathIterator sample code for java.awt.Shape.getPathIterator(java.awt.geom.AffineTransform) definition code for java.awt.Shape.getPathIterator(java.awt.geom.AffineTransform) , getPathIterator sample code for java.awt.Shape.getPathIterator(java.awt.geom.AffineTransform, double) definition code for java.awt.Shape.getPathIterator(java.awt.geom.AffineTransform, double) , intersects sample code for java.awt.Shape.intersects(double, double, double, double) definition code for java.awt.Shape.intersects(double, double, double, double) , intersects sample code for java.awt.Shape.intersects(java.awt.geom.Rectangle2D) definition code for java.awt.Shape.intersects(java.awt.geom.Rectangle2D)
 

Field Detail

UPDATE_WHEN_ON_EDT sample code for javax.swing.text.DefaultCaret.UPDATE_WHEN_ON_EDT

public 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.

Since:
1.5
See Also:
setUpdatePolicy(int) sample code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) definition code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) , getUpdatePolicy() sample code for javax.swing.text.DefaultCaret.getUpdatePolicy() definition code for javax.swing.text.DefaultCaret.getUpdatePolicy() , Constant Field Values

NEVER_UPDATE sample code for javax.swing.text.DefaultCaret.NEVER_UPDATE

public 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. In that case the caret position is adjusted to the end of the document.

Since:
1.5
See Also:
setUpdatePolicy(int) sample code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) definition code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) , getUpdatePolicy() sample code for javax.swing.text.DefaultCaret.getUpdatePolicy() definition code for javax.swing.text.DefaultCaret.getUpdatePolicy() , Constant Field Values

ALWAYS_UPDATE sample code for javax.swing.text.DefaultCaret.ALWAYS_UPDATE

public 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.

Since:
1.5
See Also:
setUpdatePolicy(int) sample code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) definition code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) , getUpdatePolicy() sample code for javax.swing.text.DefaultCaret.getUpdatePolicy() definition code for javax.swing.text.DefaultCaret.getUpdatePolicy() , Constant Field Values

listenerList sample code for javax.swing.text.DefaultCaret.listenerList

protected EventListenerList sample code for javax.swing.event.EventListenerList definition code for javax.swing.event.EventListenerList  listenerList
The event listener list.


changeEvent sample code for javax.swing.text.DefaultCaret.changeEvent

protected transient ChangeEvent sample code for javax.swing.event.ChangeEvent definition code for javax.swing.event.ChangeEvent  changeEvent
The change event for the model. Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".

Constructor Detail

DefaultCaret sample code for javax.swing.text.DefaultCaret() definition code for javax.swing.text.DefaultCaret()

public DefaultCaret()
Constructs a default caret.

Method Detail

setUpdatePolicy sample code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) definition code for javax.swing.text.DefaultCaret.setUpdatePolicy(int)

public void setUpdatePolicy(int policy)
Sets the caret movement policy on the document updates. Normally the caret updates its absolute position within the document on insertions occurred before or at the caret position and on removals before the caret position. 'Absolute position' means here the position relative to the start of the document. For example if a character is typed within editable text component it is inserted at the caret position and the caret moves to the next absolute position within the document due to insertion and if BACKSPACE is typed then caret decreases its absolute position due to removal of a character before it. Sometimes it may be useful to turn off the caret position updates so that the caret stays at the same absolute position within the document position regardless of any document updates.

The following update policies are allowed:

The default property value is UPDATE_WHEN_ON_EDT.

Parameters:
policy - one of the following values : UPDATE_WHEN_ON_EDT, NEVER_UPDATE, ALWAYS_UPDATE
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if invalid value is passed
Since:
1.5
See Also:
getUpdatePolicy() sample code for javax.swing.text.DefaultCaret.getUpdatePolicy() definition code for javax.swing.text.DefaultCaret.getUpdatePolicy() , adjustVisibility(java.awt.Rectangle) sample code for javax.swing.text.DefaultCaret.adjustVisibility(java.awt.Rectangle) definition code for javax.swing.text.DefaultCaret.adjustVisibility(java.awt.Rectangle) , UPDATE_WHEN_ON_EDT sample code for javax.swing.text.DefaultCaret.UPDATE_WHEN_ON_EDT definition code for javax.swing.text.DefaultCaret.UPDATE_WHEN_ON_EDT , NEVER_UPDATE sample code for javax.swing.text.DefaultCaret.NEVER_UPDATE definition code for javax.swing.text.DefaultCaret.NEVER_UPDATE , ALWAYS_UPDATE sample code for javax.swing.text.DefaultCaret.ALWAYS_UPDATE definition code for javax.swing.text.DefaultCaret.ALWAYS_UPDATE

getUpdatePolicy sample code for javax.swing.text.DefaultCaret.getUpdatePolicy() definition code for javax.swing.text.DefaultCaret.getUpdatePolicy()

public int getUpdatePolicy()
Gets the caret movement policy on document updates.

Returns:
one of the following values : UPDATE_WHEN_ON_EDT, NEVER_UPDATE, ALWAYS_UPDATE
Since:
1.5
See Also:
setUpdatePolicy(int) sample code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) definition code for javax.swing.text.DefaultCaret.setUpdatePolicy(int) , UPDATE_WHEN_ON_EDT sample code for javax.swing.text.DefaultCaret.UPDATE_WHEN_ON_EDT definition code for javax.swing.text.DefaultCaret.UPDATE_WHEN_ON_EDT , NEVER_UPDATE sample code for javax.swing.text.DefaultCaret.NEVER_UPDATE definition code for javax.swing.text.DefaultCaret.NEVER_UPDATE , ALWAYS_UPDATE sample code for javax.swing.text.DefaultCaret.ALWAYS_UPDATE definition code for javax.swing.text.DefaultCaret.ALWAYS_UPDATE

getComponent sample code for javax.swing.text.DefaultCaret.getComponent() definition code for javax.swing.text.DefaultCaret.getComponent()

protected final JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  getComponent()
Gets the text editor component that this caret is is bound to.

Returns:
the component

repaint sample code for javax.swing.text.DefaultCaret.repaint() definition code for javax.swing.text.DefaultCaret.repaint()

protected final void repaint()
Cause the caret to be painted. The repaint area is the bounding box of the caret (i.e. the caret rectangle or this).

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.


damage sample code for javax.swing.text.DefaultCaret.damage(java.awt.Rectangle) definition code for javax.swing.text.DefaultCaret.damage(java.awt.Rectangle)

protected void damage(Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  r)
Damages the area surrounding the caret to cause it to be repainted in a new location. If paint() is reimplemented, this method should also be reimplemented. This method should update the caret bounds (x, y, width, and height).

Parameters:
r - the current location of the caret
See Also:
paint(java.awt.Graphics) sample code for javax.swing.text.DefaultCaret.paint(java.awt.Graphics) definition code for javax.swing.text.DefaultCaret.paint(java.awt.Graphics)

adjustVisibility sample code for javax.swing.text.DefaultCaret.adjustVisibility(java.awt.Rectangle) definition code for javax.swing.text.DefaultCaret.adjustVisibility(java.awt.Rectangle)

protected void adjustVisibility(Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  nloc)
Scrolls the associated view (if necessary) to make the caret visible. Since how this should be done is somewhat of a policy, this method can be reimplemented to change the behavior. By default the scrollRectToVisible method is called on the associated component.

Parameters:
nloc - the new position to scroll to

getSelectionPainter sample code for javax.swing.text.DefaultCaret.getSelectionPainter() definition code for javax.swing.text.DefaultCaret.getSelectionPainter()

protected Highlighter.HighlightPainter sample code for javax.swing.text.Highlighter.HighlightPainter definition code for javax.swing.text.Highlighter.HighlightPainter  getSelectionPainter()
Gets the painter for the Highlighter.

Returns:
the painter

positionCaret sample code for javax.swing.text.DefaultCaret.positionCaret(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.positionCaret(java.awt.event.MouseEvent)

protected void positionCaret(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Tries to set the position of the caret from the coordinates of a mouse event, using viewToModel().

Parameters:
e - the mouse event

moveCaret sample code for javax.swing.text.DefaultCaret.moveCaret(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.moveCaret(java.awt.event.MouseEvent)

protected void moveCaret(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Tries to move the position of the caret from the coordinates of a mouse event, using viewToModel(). This will cause a selection if the dot and mark are different.

Parameters:
e - the mouse event

focusGained sample code for javax.swing.text.DefaultCaret.focusGained(java.awt.event.FocusEvent) definition code for javax.swing.text.DefaultCaret.focusGained(java.awt.event.FocusEvent)

public void focusGained(FocusEvent sample code for java.awt.event.FocusEvent definition code for java.awt.event.FocusEvent  e)
Called when the component containing the caret gains focus. This is implemented to set the caret to visible if the component is editable.

Specified by:
focusGained sample code for java.awt.event.FocusListener.focusGained(java.awt.event.FocusEvent) definition code for java.awt.event.FocusListener.focusGained(java.awt.event.FocusEvent) in interface FocusListener sample code for java.awt.event.FocusListener definition code for java.awt.event.FocusListener
Parameters:
e - the focus event
See Also:
FocusListener.focusGained(java.awt.event.FocusEvent) sample code for java.awt.event.FocusListener.focusGained(java.awt.event.FocusEvent) definition code for java.awt.event.FocusListener.focusGained(java.awt.event.FocusEvent)

focusLost sample code for javax.swing.text.DefaultCaret.focusLost(java.awt.event.FocusEvent) definition code for javax.swing.text.DefaultCaret.focusLost(java.awt.event.FocusEvent)

public void focusLost(FocusEvent sample code for java.awt.event.FocusEvent definition code for java.awt.event.FocusEvent  e)
Called when the component containing the caret loses focus. This is implemented to set the caret to visibility to false.

Specified by:
focusLost sample code for java.awt.event.FocusListener.focusLost(java.awt.event.FocusEvent) definition code for java.awt.event.FocusListener.focusLost(java.awt.event.FocusEvent) in interface FocusListener sample code for java.awt.event.FocusListener definition code for java.awt.event.FocusListener
Parameters:
e - the focus event
See Also:
FocusListener.focusLost(java.awt.event.FocusEvent) sample code for java.awt.event.FocusListener.focusLost(java.awt.event.FocusEvent) definition code for java.awt.event.FocusListener.focusLost(java.awt.event.FocusEvent)

mouseClicked sample code for javax.swing.text.DefaultCaret.mouseClicked(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseClicked(java.awt.event.MouseEvent)

public void mouseClicked(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Called when the mouse is clicked. If the click was generated from button1, a double click selects a word, and a triple click the current line.

Specified by:
mouseClicked sample code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent) sample code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseClicked(java.awt.event.MouseEvent)

mousePressed sample code for javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mousePressed(java.awt.event.MouseEvent)

public void mousePressed(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
If button 1 is pressed, this is implemented to request focus on the associated text component, and to set the caret position. If the shift key is held down, the caret will be moved, potentially resulting in a selection, otherwise the caret position will be set to the new location. If the component is not enabled, there will be no request for focus.

Specified by:
mousePressed sample code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent) sample code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased sample code for javax.swing.text.DefaultCaret.mouseReleased(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseReleased(java.awt.event.MouseEvent)

public void mouseReleased(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Called when the mouse is released.

Specified by:
mouseReleased sample code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent) sample code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered sample code for javax.swing.text.DefaultCaret.mouseEntered(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseEntered(java.awt.event.MouseEvent)

public void mouseEntered(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Called when the mouse enters a region.

Specified by:
mouseEntered sample code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent) sample code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited sample code for javax.swing.text.DefaultCaret.mouseExited(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseExited(java.awt.event.MouseEvent)

public void mouseExited(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Called when the mouse exits a region.

Specified by:
mouseExited sample code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) in interface MouseListener sample code for java.awt.event.MouseListener definition code for java.awt.event.MouseListener
Parameters:
e - the mouse event
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent) sample code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent) definition code for java.awt.event.MouseListener.mouseExited(java.awt.event.MouseEvent)

mouseDragged sample code for javax.swing.text.DefaultCaret.mouseDragged(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseDragged(java.awt.event.MouseEvent)

public void mouseDragged(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Moves the caret position according to the mouse pointer's current location. This effectively extends the selection. By default, this is only done for mouse button 1.

Specified by:
mouseDragged sample code for java.awt.event.MouseMotionListener.mouseDragged(java.awt.event.MouseEvent) definition code for java.awt.event.MouseMotionListener.mouseDragged(java.awt.event.MouseEvent) in interface MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener
Parameters:
e - the mouse event
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent) sample code for java.awt.event.MouseMotionListener.mouseDragged(java.awt.event.MouseEvent) definition code for java.awt.event.MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

mouseMoved sample code for javax.swing.text.DefaultCaret.mouseMoved(java.awt.event.MouseEvent) definition code for javax.swing.text.DefaultCaret.mouseMoved(java.awt.event.MouseEvent)

public void mouseMoved(MouseEvent sample code for java.awt.event.MouseEvent definition code for java.awt.event.MouseEvent  e)
Called when the mouse is moved.

Specified by:
mouseMoved sample code for java.awt.event.MouseMotionListener.mouseMoved(java.awt.event.MouseEvent) definition code for java.awt.event.MouseMotionListener.mouseMoved(java.awt.event.MouseEvent) in interface MouseMotionListener sample code for java.awt.event.MouseMotionListener definition code for java.awt.event.MouseMotionListener
Parameters:
e - the mouse event
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent) sample code for java.awt.event.MouseMotionListener.mouseMoved(java.awt.event.MouseEvent) definition code for java.awt.event.MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

paint sample code for javax.swing.text.DefaultCaret.paint(java.awt.Graphics) definition code for javax.swing.text.DefaultCaret.paint(java.awt.Graphics)

public void paint(Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g)
Renders the caret as a vertical line. If this is reimplemented the damage method should also be reimplemented as it assumes the shape of the caret is a vertical line. Sets the caret color to the value returned by getCaretColor().

If there are multiple text directions present in the associated document, a flag indicating the caret bias will be rendered. This will occur only if the associated document is a subclass of AbstractDocument and there are multiple bidi levels present in the bidi element structure (i.e. the text has multiple directions associated with it).

Specified by:
paint sample code for javax.swing.text.Caret.paint(java.awt.Graphics) definition code for javax.swing.text.Caret.paint(java.awt.Graphics) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
g - the graphics context
See Also:
damage(java.awt.Rectangle) sample code for javax.swing.text.DefaultCaret.damage(java.awt.Rectangle) definition code for javax.swing.text.DefaultCaret.damage(java.awt.Rectangle)

install sample code for javax.swing.text.DefaultCaret.install(javax.swing.text.JTextComponent) definition code for javax.swing.text.DefaultCaret.install(javax.swing.text.JTextComponent)

public void install(JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  c)
Called when the UI is being installed into the interface of a JTextComponent. This can be used to gain access to the model that is being navigated by the implementation of this interface. Sets the dot and mark to 0, and establishes document, property change, focus, mouse, and mouse motion listeners.

Specified by:
install sample code for javax.swing.text.Caret.install(javax.swing.text.JTextComponent) definition code for javax.swing.text.Caret.install(javax.swing.text.JTextComponent) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
c - the component
See Also:
Caret.install(javax.swing.text.JTextComponent) sample code for javax.swing.text.Caret.install(javax.swing.text.JTextComponent) definition code for javax.swing.text.Caret.install(javax.swing.text.JTextComponent)

deinstall sample code for javax.swing.text.DefaultCaret.deinstall(javax.swing.text.JTextComponent) definition code for javax.swing.text.DefaultCaret.deinstall(javax.swing.text.JTextComponent)

public void deinstall(JTextComponent sample code for javax.swing.text.JTextComponent definition code for javax.swing.text.JTextComponent  c)
Called when the UI is being removed from the interface of a JTextComponent. This is used to unregister any listeners that were attached.

Specified by:
deinstall sample code for javax.swing.text.Caret.deinstall(javax.swing.text.JTextComponent) definition code for javax.swing.text.Caret.deinstall(javax.swing.text.JTextComponent) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
c - the component
See Also:
Caret.deinstall(javax.swing.text.JTextComponent) sample code for javax.swing.text.Caret.deinstall(javax.swing.text.JTextComponent) definition code for javax.swing.text.Caret.deinstall(javax.swing.text.JTextComponent)

addChangeListener sample code for javax.swing.text.DefaultCaret.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.DefaultCaret.addChangeListener(javax.swing.event.ChangeListener)

public void addChangeListener(ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
Adds a listener to track whenever the caret position has been changed.

Specified by:
addChangeListener sample code for javax.swing.text.Caret.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.Caret.addChangeListener(javax.swing.event.ChangeListener) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
l - the listener
See Also:
Caret.addChangeListener(javax.swing.event.ChangeListener) sample code for javax.swing.text.Caret.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.Caret.addChangeListener(javax.swing.event.ChangeListener)

removeChangeListener sample code for javax.swing.text.DefaultCaret.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.DefaultCaret.removeChangeListener(javax.swing.event.ChangeListener)

public void removeChangeListener(ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
Removes a listener that was tracking caret position changes.

Specified by:
removeChangeListener sample code for javax.swing.text.Caret.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.Caret.removeChangeListener(javax.swing.event.ChangeListener) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
l - the listener
See Also:
Caret.removeChangeListener(javax.swing.event.ChangeListener) sample code for javax.swing.text.Caret.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.Caret.removeChangeListener(javax.swing.event.ChangeListener)

getChangeListeners sample code for javax.swing.text.DefaultCaret.getChangeListeners() definition code for javax.swing.text.DefaultCaret.getChangeListeners()

public ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener [] getChangeListeners()
Returns an array of all the change listeners registered on this caret.

Returns:
all of this caret's ChangeListeners or an empty array if no change listeners are currently registered
Since:
1.4
See Also:
addChangeListener(javax.swing.event.ChangeListener) sample code for javax.swing.text.DefaultCaret.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.DefaultCaret.addChangeListener(javax.swing.event.ChangeListener) , removeChangeListener(javax.swing.event.ChangeListener) sample code for javax.swing.text.DefaultCaret.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.DefaultCaret.removeChangeListener(javax.swing.event.ChangeListener)

fireStateChanged sample code for javax.swing.text.DefaultCaret.fireStateChanged() definition code for javax.swing.text.DefaultCaret.fireStateChanged()

protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method. The listener list is processed last to first.

See Also:
EventListenerList sample code for javax.swing.event.EventListenerList definition code for javax.swing.event.EventListenerList

getListeners sample code for javax.swing.text.DefaultCaret.<T extends java.util.EventListener>getListeners(java.lang.Class<T>) definition code for javax.swing.text.DefaultCaret.<T extends java.util.EventListener>getListeners(java.lang.Class<T>)

public <T extends EventListener sample code for java.util.EventListener definition code for java.util.EventListener > T[] getListeners(Class sample code for java.lang.Class definition code for java.lang.Class <T> listenerType)
Returns an array of all the objects currently registered as FooListeners upon this caret. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultCaret c for its change listeners with the following code:

ChangeListener[] cls = (ChangeListener[])(c.getListeners(ChangeListener.class));
If no such listeners exist, this method returns an empty array.

Parameters:
listenerType - the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
Returns:
an array of all objects registered as FooListeners on this component, or an empty array if no such listeners have been added
Throws:
ClassCastException sample code for java.lang.ClassCastException definition code for java.lang.ClassCastException - if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since:
1.3
See Also:
getChangeListeners() sample code for javax.swing.text.DefaultCaret.getChangeListeners() definition code for javax.swing.text.DefaultCaret.getChangeListeners()

setSelectionVisible sample code for javax.swing.text.DefaultCaret.setSelectionVisible(boolean) definition code for javax.swing.text.DefaultCaret.setSelectionVisible(boolean)

public void setSelectionVisible(boolean vis)
Changes the selection visibility.

Specified by:
setSelectionVisible sample code for javax.swing.text.Caret.setSelectionVisible(boolean) definition code for javax.swing.text.Caret.setSelectionVisible(boolean) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
vis - the new visibility

isSelectionVisible sample code for javax.swing.text.DefaultCaret.isSelectionVisible() definition code for javax.swing.text.DefaultCaret.isSelectionVisible()

public boolean isSelectionVisible()
Checks whether the current selection is visible.

Specified by:
isSelectionVisible sample code for javax.swing.text.Caret.isSelectionVisible() definition code for javax.swing.text.Caret.isSelectionVisible() in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Returns:
true if the selection is visible

isActive sample code for javax.swing.text.DefaultCaret.isActive() definition code for javax.swing.text.DefaultCaret.isActive()

public boolean isActive()
Determines if the caret is currently active.

This method returns whether or not the Caret is currently in a blinking state. It does not provide information as to whether it is currently blinked on or off. To determine if the caret is currently painted use the isVisible method.

Returns:
true if active else false
Since:
1.5
See Also:
isVisible() sample code for javax.swing.text.DefaultCaret.isVisible() definition code for javax.swing.text.DefaultCaret.isVisible()

isVisible sample code for javax.swing.text.DefaultCaret.isVisible() definition code for javax.swing.text.DefaultCaret.isVisible()

public boolean isVisible()
Indicates whether or not the caret is currently visible. As the caret flashes on and off the return value of this will change between true, when the caret is painted, and false, when the caret is not painted. isActive indicates whether or not the caret is in a blinking state, such that it can be visible, and isVisible indicates whether or not the caret is actually visible.

Subclasses that wish to render a different flashing caret should override paint and only paint the caret if this method returns true.

Specified by:
isVisible sample code for javax.swing.text.Caret.isVisible() definition code for javax.swing.text.Caret.isVisible() in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Returns:
true if visible else false
See Also:
Caret.isVisible() sample code for javax.swing.text.Caret.isVisible() definition code for javax.swing.text.Caret.isVisible() , isActive() sample code for javax.swing.text.DefaultCaret.isActive() definition code for javax.swing.text.DefaultCaret.isActive()

setVisible sample code for javax.swing.text.DefaultCaret.setVisible(boolean) definition code for javax.swing.text.DefaultCaret.setVisible(boolean)

public void setVisible(boolean e)
Sets the caret visibility, and repaints the caret. It is important to understand the relationship between this method, isVisible and isActive. Calling this method with a value of true activates the caret blinking. Setting it to false turns it completely off. To determine whether the blinking is active, you should call isActive. In effect, isActive is an appropriate corresponding "getter" method for this one. isVisible can be used to fetch the current visibility status of the caret, meaning whether or not it is currently painted. This status will change as the caret blinks on and off.

Here's a list showing the potential return values of both isActive and isVisible after calling this method:

setVisible(true):

setVisible(false):

Specified by:
setVisible sample code for javax.swing.text.Caret.setVisible(boolean) definition code for javax.swing.text.Caret.setVisible(boolean) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
e - the visibility specifier
See Also:
isActive() sample code for javax.swing.text.DefaultCaret.isActive() definition code for javax.swing.text.DefaultCaret.isActive() , Caret.setVisible(boolean) sample code for javax.swing.text.Caret.setVisible(boolean) definition code for javax.swing.text.Caret.setVisible(boolean)

setBlinkRate sample code for javax.swing.text.DefaultCaret.setBlinkRate(int) definition code for javax.swing.text.DefaultCaret.setBlinkRate(int)

public void setBlinkRate(int rate)
Sets the caret blink rate.

Specified by:
setBlinkRate sample code for javax.swing.text.Caret.setBlinkRate(int) definition code for javax.swing.text.Caret.setBlinkRate(int) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
rate - the rate in milliseconds, 0 to stop blinking
See Also:
Caret.setBlinkRate(int) sample code for javax.swing.text.Caret.setBlinkRate(int) definition code for javax.swing.text.Caret.setBlinkRate(int)

getBlinkRate sample code for javax.swing.text.DefaultCaret.getBlinkRate() definition code for javax.swing.text.DefaultCaret.getBlinkRate()

public int getBlinkRate()
Gets the caret blink rate.

Specified by:
getBlinkRate sample code for javax.swing.text.Caret.getBlinkRate() definition code for javax.swing.text.Caret.getBlinkRate() in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Returns:
the delay in milliseconds. If this is zero the caret will not blink.
See Also:
Caret.getBlinkRate() sample code for javax.swing.text.Caret.getBlinkRate() definition code for javax.swing.text.Caret.getBlinkRate()

getDot sample code for javax.swing.text.DefaultCaret.getDot() definition code for javax.swing.text.DefaultCaret.getDot()

public int getDot()
Fetches the current position of the caret.

Specified by:
getDot sample code for javax.swing.text.Caret.getDot() definition code for javax.swing.text.Caret.getDot() in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Returns:
the position >= 0
See Also:
Caret.getDot() sample code for javax.swing.text.Caret.getDot() definition code for javax.swing.text.Caret.getDot()

getMark sample code for javax.swing.text.DefaultCaret.getMark() definition code for javax.swing.text.DefaultCaret.getMark()

public int getMark()
Fetches the current position of the mark. If there is a selection, the dot and mark will not be the same.

Specified by:
getMark sample code for javax.swing.text.Caret.getMark() definition code for javax.swing.text.Caret.getMark() in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Returns:
the position >= 0
See Also:
Caret.getMark() sample code for javax.swing.text.Caret.getMark() definition code for javax.swing.text.Caret.getMark()

setDot sample code for javax.swing.text.DefaultCaret.setDot(int) definition code for javax.swing.text.DefaultCaret.setDot(int)

public void setDot(int dot)
Sets the caret position and mark to some position. This implicitly sets the selection range to zero.

Specified by:
setDot sample code for javax.swing.text.Caret.setDot(int) definition code for javax.swing.text.Caret.setDot(int) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
dot - the position >= 0
See Also:
Caret.setDot(int) sample code for javax.swing.text.Caret.setDot(int) definition code for javax.swing.text.Caret.setDot(int)

moveDot sample code for javax.swing.text.DefaultCaret.moveDot(int) definition code for javax.swing.text.DefaultCaret.moveDot(int)

public void moveDot(int dot)
Moves the caret position to some other position.

Specified by:
moveDot sample code for javax.swing.text.Caret.moveDot(int) definition code for javax.swing.text.Caret.moveDot(int) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
dot - the position >= 0
See Also:
Caret.moveDot(int) sample code for javax.swing.text.Caret.moveDot(int) definition code for javax.swing.text.Caret.moveDot(int)

setMagicCaretPosition sample code for javax.swing.text.DefaultCaret.setMagicCaretPosition(java.awt.Point) definition code for javax.swing.text.DefaultCaret.setMagicCaretPosition(java.awt.Point)

public void setMagicCaretPosition(Point sample code for java.awt.Point definition code for java.awt.Point  p)
Saves the current caret position. This is used when caret up/down actions occur, moving between lines that have uneven end positions.

Specified by:
setMagicCaretPosition sample code for javax.swing.text.Caret.setMagicCaretPosition(java.awt.Point) definition code for javax.swing.text.Caret.setMagicCaretPosition(java.awt.Point) in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Parameters:
p - the position
See Also:
getMagicCaretPosition() sample code for javax.swing.text.DefaultCaret.getMagicCaretPosition() definition code for javax.swing.text.DefaultCaret.getMagicCaretPosition()

getMagicCaretPosition sample code for javax.swing.text.DefaultCaret.getMagicCaretPosition() definition code for javax.swing.text.DefaultCaret.getMagicCaretPosition()

public Point sample code for java.awt.Point definition code for java.awt.Point  getMagicCaretPosition()
Gets the saved caret position.

Specified by:
getMagicCaretPosition sample code for javax.swing.text.Caret.getMagicCaretPosition() definition code for javax.swing.text.Caret.getMagicCaretPosition() in interface Caret sample code for javax.swing.text.Caret definition code for javax.swing.text.Caret
Returns:
the position see #setMagicCaretPosition
See Also:
Caret.setMagicCaretPosition(java.awt.Point) sample code for javax.swing.text.Caret.setMagicCaretPosition(java.awt.Point) definition code for javax.swing.text.Caret.setMagicCaretPosition(java.awt.Point)

equals sample code for javax.swing.text.DefaultCaret.equals(java.lang.Object) definition code for javax.swing.text.DefaultCaret.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Compares this object to the specified object. The superclass behavior of comparing rectangles is not desired, so this is changed to the Object behavior.

Overrides:
equals sample code for java.awt.Rectangle.equals(java.lang.Object) definition code for java.awt.Rectangle.equals(java.lang.Object) in class Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle
Parameters:
obj - the object to compare this font with
Returns:
true if the objects are equal; false otherwise
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for javax.swing.text.DefaultCaret.toString() definition code for javax.swing.text.DefaultCaret.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Description copied from class: Rectangle sample code for java.awt.Rectangle.toString() definition code for java.awt.Rectangle.toString()
Returns a String representing this Rectangle and its values.

Overrides:
toString sample code for java.awt.Rectangle.toString() definition code for java.awt.Rectangle.toString() in class Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle
Returns:
a String representing this Rectangle object's coordinate and size values.