Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.swt.widgets
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 intended to be subclassed only within the SWT implementation.

Constructor Summary
`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
`Rectangle` | `getBounds()` Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).
`Font` | `getFont()` Returns the font that the receiver will use to paint textual information.
`Image` | `getImage()` Returns the image that the receiver will use to paint the caret.
`Point` | `getLocation()` Returns a point describing the receiver's location relative to its parent (or its display if its parent is null).
`Canvas` | `getParent()` Returns the receiver's parent, which must be a `Canvas`.
`Point` | `getSize()` Returns a point describing the receiver's size.
`boolean` | `getVisible()` Returns `true` if the receiver is visible, and `false` otherwise.
`boolean` | `isVisible()` 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` | `setBounds(Rectangle rect)` 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.

Methods inherited from class org.eclipse.swt.widgets.Widget
`addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### 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:
  `SWT`, `Widget.checkSubclass()`, `Widget.getStyle()`

Method Detail

### 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:
    `getVisible()`

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Eclipse Platform Release 3.0
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.