Class Caret

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Caret

public class Caret extends Widget
Instances of this class provide an i-beam that is typically used as the insertion point for text.
Styles:
(none)
Events:
(none)

IMPORTANT: This class is not intended to be subclassed.

See Also:
Restriction:
This class is not intended to be subclassed by clients.
  • Field Summary

    Fields inherited from class org.eclipse.swt.widgets.Widget

    nativeZoom
  • Constructor Summary

    Constructors
    Constructor
    Description
    Caret(Canvas parent, int style)
    Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).
    Returns the font that the receiver will use to paint textual information.
    Returns the image that the receiver will use to paint the caret.
    Returns a point describing the receiver's location relative to its parent (or its display if its parent is null).
    Returns the receiver's parent, which must be a Canvas.
    Returns a point describing the receiver's size.
    boolean
    Returns true if the receiver is visible, and false otherwise.
    boolean
    Returns true if the receiver is visible and all of the receiver's ancestors are visible and false otherwise.
    void
    setBounds(int x, int y, int width, int height)
    Sets the receiver's size and location to the rectangular area specified by the arguments.
    void
    Sets the receiver's size and location to the rectangular area specified by the argument.
    void
    setFont(Font font)
    Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
    void
    setImage(Image image)
    Sets the image that the receiver will use to paint the caret to the image specified by the argument, or to the default which is a filled rectangle if the argument is null
    void
    setLocation(int x, int y)
    Sets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null).
    void
    setLocation(Point location)
    Sets the receiver's location to the point specified by the argument which is relative to the receiver's parent (or its display if its parent is null).
    void
    setSize(int width, int height)
    Sets the receiver's size to the point specified by the arguments.
    void
    setSize(Point size)
    Sets the receiver's size to the point specified by the argument.
    void
    setVisible(boolean visible)
    Marks the receiver as visible if the argument is true, and marks it invisible otherwise.
    static void
    win32_setHeight(Caret caret, int height)
    IMPORTANT: This method is not part of the public API for Image.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Caret

      public Caret(Canvas parent, int style)
      Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

      The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

      Parameters:
      parent - a composite control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the parent is null
      SWTException -
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
      • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
      See Also:
  • Method Details

    • getBounds

      public Rectangle getBounds()
      Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).
      Returns:
      the receiver's bounding rectangle
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getFont

      public Font getFont()
      Returns the font that the receiver will use to paint textual information.
      Returns:
      the receiver's font
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getImage

      public Image getImage()
      Returns the image that the receiver will use to paint the caret.
      Returns:
      the receiver's image
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getLocation

      public Point getLocation()
      Returns a point describing the receiver's location relative to its parent (or its display if its parent is null).
      Returns:
      the receiver's location
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getParent

      public Canvas getParent()
      Returns the receiver's parent, which must be a Canvas.
      Returns:
      the receiver's parent
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getSize

      public Point getSize()
      Returns a point describing the receiver's size.
      Returns:
      the receiver's size
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • getVisible

      public boolean getVisible()
      Returns true if the receiver is visible, and false otherwise.

      If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing.

      Returns:
      the receiver's visibility state
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • isVisible

      public boolean isVisible()
      Returns true if the receiver is visible and all of the receiver's ancestors are visible and false otherwise.
      Returns:
      the receiver's visibility state
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      See Also:
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Sets the receiver's size and location to the rectangular area specified by the arguments. The x and y arguments are relative to the receiver's parent (or its display if its parent is null).
      Parameters:
      x - the new x coordinate for the receiver
      y - the new y coordinate for the receiver
      width - the new width for the receiver
      height - the new height for the receiver
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setBounds

      public void setBounds(Rectangle rect)
      Sets the receiver's size and location to the rectangular area specified by the argument. The x and y fields of the rectangle are relative to the receiver's parent (or its display if its parent is null).
      Parameters:
      rect - the new bounds for the receiver
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setFont

      public void setFont(Font font)
      Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
      Parameters:
      font - the new font (or null)
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the font has been disposed
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setImage

      public void setImage(Image image)
      Sets the image that the receiver will use to paint the caret to the image specified by the argument, or to the default which is a filled rectangle if the argument is null
      Parameters:
      image - the new image (or null)
      Throws:
      IllegalArgumentException -
      • ERROR_INVALID_ARGUMENT - if the image has been disposed
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setLocation

      public void setLocation(int x, int y)
      Sets the receiver's location to the point specified by the arguments which are relative to the receiver's parent (or its display if its parent is null).
      Parameters:
      x - the new x coordinate for the receiver
      y - the new y coordinate for the receiver
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setLocation

      public void setLocation(Point location)
      Sets the receiver's location to the point specified by the argument which is relative to the receiver's parent (or its display if its parent is null).
      Parameters:
      location - the new location for the receiver
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setSize

      public void setSize(int width, int height)
      Sets the receiver's size to the point specified by the arguments.
      Parameters:
      width - the new width for the receiver
      height - the new height for the receiver
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setSize

      public void setSize(Point size)
      Sets the receiver's size to the point specified by the argument.
      Parameters:
      size - the new extent for the receiver
      Throws:
      IllegalArgumentException -
      • ERROR_NULL_ARGUMENT - if the point is null
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • setVisible

      public void setVisible(boolean visible)
      Marks the receiver as visible if the argument is true, and marks it invisible otherwise.

      If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed.

      Parameters:
      visible - the new visibility state
      Throws:
      SWTException -
      • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
      • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
    • win32_setHeight

      public static void win32_setHeight(Caret caret, int height)
      IMPORTANT: This method is not part of the public API for Image. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code. Sets the height o the caret in points.
      Parameters:
      caret - the caret to set the height of
      height - the height of caret to be set in points.
      Restriction:
      This method is not intended to be referenced by clients.