Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.text
Interface Caret

All Known Implementing Classes:
  DefaultCaret

public abstract interface Caret

A place within a document view that represents where things can be inserted into the document model. It gives a way to navigate through the document view while abstracting away the details of how the view is arranged. This can be useful because some views may filter out portions of the associated model, and some views may not allow navigation in certain areas such as read-only areas.

Method Summary
`void` | `addChangeListener(ChangeListener l)` Adds a listener to track whenever the caret position has been changed.
`void` | `deinstall(JTextComponent c)` Called when the UI is being removed from the interface of a JTextComponent.
`int` | `getBlinkRate()` Gets the blink rate of the caret.
`int` | `getDot()` Fetches the current position of the caret.
`java.awt.Point` | `getMagicCaretPosition()` Gets the current caret position.
`int` | `getMark()` Fetches the current position of the mark.
`void` | `install(JTextComponent c)` Called when the UI is being installed into the interface of a JTextComponent.
`boolean` | `isSelectionVisible()` Determines if the selection is currently visible.
`boolean` | `isVisible()` Determines if the caret is currently visible.
`void` | `moveDot(int dot)` Moves the caret position to some other position, leaving behind the mark.
`void` | `paint(java.awt.Graphics g)` Renders the caret.
`void` | `removeChangeListener(ChangeListener l)` Removes a listener that was tracking caret position changes.
`void` | `setBlinkRate(int rate)` Sets the blink rate of the caret.
`void` | `setDot(int dot)` Sets the caret position to some position.
`void` | `setMagicCaretPosition(java.awt.Point p)` Saves the current caret position.
`void` | `setSelectionVisible(boolean v)` Sets the visibility of the selection
`void` | `setVisible(boolean v)` Sets the visibility of the caret.

Method Detail

### install

    public void install(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.
  Parameters:
    `c` - the JTextComponent

### deinstall

    public void deinstall(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.
  Parameters:
    `c` - the JTextComponent

### paint

    public void paint(java.awt.Graphics g)

  Renders the caret.
  Parameters:
    `g` - the graphics context

### addChangeListener

    public void addChangeListener(ChangeListener l)

  Adds a listener to track whenever the caret position has been changed.
  Parameters:
    `l` - the change listener

### removeChangeListener

    public void removeChangeListener(ChangeListener l)

  Removes a listener that was tracking caret position changes.
  Parameters:
    `l` - the change listener

### isVisible

    public boolean isVisible()

  Determines if the caret is currently visible.
  Returns:
    true if the caret is visible else false

### setVisible

    public void setVisible(boolean v)

  Sets the visibility of the caret.
  Parameters:
    `v` - true if the caret should be shown, and false if the caret should be hidden

### isSelectionVisible

    public boolean isSelectionVisible()

  Determines if the selection is currently visible.
  Returns:
    true if the caret is visible else false

### setSelectionVisible

    public void setSelectionVisible(boolean v)

  Sets the visibility of the selection
  Parameters:
    `v` - true if the caret should be shown, and false if the caret should be hidden

### setMagicCaretPosition

    public void setMagicCaretPosition(java.awt.Point p)

  Saves the current caret position. This is used when caret up or down actions occur, moving between lines that have uneven end positions.
  Parameters:
    `p` - the Point to use for the saved position

### getMagicCaretPosition

    public java.awt.Point getMagicCaretPosition()

  Gets the current caret position.
  Returns:
    the position
  See Also:
    `setMagicCaretPosition(java.awt.Point)`

### setBlinkRate

    public void setBlinkRate(int rate)

  Sets the blink rate of the caret. This determines if and how fast the caret blinks, commonly used as one way to attract attention to the caret.
  Parameters:
    `rate` - the delay in milliseconds >= 0. If this is zero the caret will not blink.

### getBlinkRate

    public int getBlinkRate()

  Gets the blink rate of the caret. This determines if and how fast the caret blinks, commonly used as one way to attract attention to the caret.

### getDot

    public int getDot()

  Fetches the current position of the caret.
  Returns:
    the position >= 0

### getMark

    public int getMark()

  Fetches the current position of the mark. If there is a selection, the mark will not be the same as the dot.
  Returns:
    the position >= 0

### setDot

    public void setDot(int dot)

  Sets the caret position to some position. This causes the mark to become the same as the dot, effectively setting the selection range to zero.
  Parameters:
    `dot` - the new position to set the caret to >= 0

### moveDot

    public void moveDot(int dot)

  Moves the caret position to some other position, leaving behind the mark. This is useful for making selections.
  Parameters:
    `dot` - the new position to move the caret to >= 0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.