Class ConfigurableCaret

  • All Implemented Interfaces:
    FocusListener, MouseListener, MouseMotionListener, Shape, Serializable, Cloneable, EventListener, Caret

    public class ConfigurableCaret
    extends DefaultCaret
    The caret used by RTextArea. This caret has all of the properties that javax.swing.text.DefaultCaret does, as well as adding the following niceties:
    • This caret can render itself many different ways; see the setStyle(CaretStyle) method and CaretStyle for more information.
    • On Microsoft Windows and other operating systems that do not support system selection (i.e., selecting text, then pasting via the middle mouse button), clicking the middle mouse button will cause a regular paste operation to occur. On systems that support system selection (i.e., all UNIX variants), the middle mouse button will behave normally.
    See Also:
    Serialized Form
    • Method Detail

      • damage

        protected void damage​(Rectangle r)
        Overridden to damage the correct width of the caret, since this caret can be different sizes.
        Overrides:
        damage in class DefaultCaret
        Parameters:
        r - The current location of the caret.
      • getTextArea

        protected RTextArea getTextArea()
        Gets the text editor component that this caret is bound to.
        Returns:
        The RTextArea.
      • getRoundedSelectionEdges

        public boolean getRoundedSelectionEdges()
        Returns whether this caret's selection uses rounded edges.
        Returns:
        Whether this caret's edges are rounded.
        See Also:
        setRoundedSelectionEdges(boolean)
      • isAlwaysVisible

        public boolean isAlwaysVisible()
        Returns whether this caret is always visible (as opposed to blinking, or not visible when the editor's window is not focused). This can be used by popup windows that want the caret's location to still be visible for contextual purposes while they are displayed.
        Returns:
        Whether this caret is always visible.
        See Also:
        setAlwaysVisible(boolean)
      • paint

        public void paint​(Graphics g)
        Paints the cursor.
        Specified by:
        paint in interface Caret
        Overrides:
        paint in class DefaultCaret
        Parameters:
        g - The graphics context in which to paint.
      • setAlwaysVisible

        public void setAlwaysVisible​(boolean alwaysVisible)
        Toggles whether this caret should always be visible (as opposed to blinking, or not visible when the editor's window is not focused). This can be used by popup windows that want the caret's location to still be visible for contextual purposes while they are displayed.
        Parameters:
        alwaysVisible - Whether this caret should always be visible.
        See Also:
        isAlwaysVisible()
      • setRoundedSelectionEdges

        public void setRoundedSelectionEdges​(boolean rounded)
        Sets whether this caret's selection should have rounded edges.
        Parameters:
        rounded - Whether it should have rounded edges.
        See Also:
        getRoundedSelectionEdges()
      • setSelectionVisible

        public void setSelectionVisible​(boolean visible)
        Overridden to always render the selection, even when the text component loses focus.
        Specified by:
        setSelectionVisible in interface Caret
        Overrides:
        setSelectionVisible in class DefaultCaret
        Parameters:
        visible - Whether the selection should be visible. This parameter is ignored.
      • setStyle

        public void setStyle​(CaretStyle style)
        Sets the style used when painting the caret.
        Parameters:
        style - The style to use. This should not be null.
        See Also:
        getStyle()