Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class Caret

extends Widget
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*

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

Important Note

This class is not intended to be subclassed.

See Also
Caret snippets, SWT Example: ControlExample, Canvas tab, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv static final int
pack-priv Composite
pack-priv Font
pack-priv int
pack-priv Image
pack-priv boolean
pack-priv boolean
pack-priv Canvas
pack-priv int
pack-priv int
x

pack-priv int
y

Inherited from org.eclipse.swt.widgets.Widget:
ACTIVATEACTIVATE_INVERSEAUTO_TEXT_DIRECTIONBACKGROUNDBACKSPACEBACKSPACE_INVERSEBUTTON_PRESS_EVENTBUTTON_PRESS_EVENT_INVERSEBUTTON_RELEASE_EVENTBUTTON_RELEASE_EVENT_INVERSECANVASCHANGE_VALUECHANGEDCHECK_SUBWINDOWCLICKEDCLOSE_REQUESTCOMMITCOMPUTE_SIZECONFIGURE_EVENTCOPY_CLIPBOARDCOPY_CLIPBOARD_INVERSECREATE_MENU_PROXYCUT_CLIPBOARDCUT_CLIPBOARD_INVERSEdataDAY_SELECTEDDAY_SELECTED_DOUBLE_CLICKDECELERATEDEFAULT_HEIGHTDELETE_EVENTDELETE_FROM_CURSORDELETE_FROM_CURSOR_INVERSEDELETE_RANGEDELETE_TEXTDIRECTION_CHANGEDDISABLEDdisplayDISPOSE_SENTDISPOSEDDPI_CHANGEDDRAG_DETECTDRAWENTERENTER_NOTIFY_EVENTEVENTEVENT_AFTEReventTableEXPAND_COLLAPSE_CURSOR_ROWEXPOSE_EVENTEXPOSE_EVENT_INVERSEFOCUSFOCUS_INFOCUS_IN_EVENTFOCUS_OUTFOCUS_OUT_EVENTFONTFOREGROUNDFOREIGN_HANDLEgdkSeatGrabPrepareFuncGESTURE_PRESSEDGESTURE_RELEASEDGRAB_FOCUShandleHANDLEHAS_AUTO_DIRECTIONHIDDENHIDEICON_RELEASEIM_UPDATEINPUTINSERT_TEXTIS_ACTIVEKEY_CHECK_SUBWINDOWKEY_GTK_CSSKEY_PRESS_EVENTKEY_PRESSEDKEY_RELEASE_EVENTKEY_RELEASEDKEYED_DATALAST_SIGNALLAYOUT_CHANGEDLAYOUT_CHILDLAYOUT_NEEDEDLEAVELEAVE_NOTIFY_EVENTMAPMAP_EVENTMENUMNEMONIC_ACTIVATEMONTH_CHANGEDMOTIONMOTION_INVERSEMOTION_NOTIFY_EVENTMOTION_NOTIFY_EVENT_INVERSEMOVE_CURSORMOVE_CURSOR_INVERSEMOVE_FOCUSMOVEDNOTIFY_DEFAULT_HEIGHTNOTIFY_DEFAULT_WIDTHNOTIFY_MAXIMIZEDNOTIFY_STATEOBSCUREDOUTPUTPARENT_BACKGROUNDPASTE_CLIPBOARDPASTE_CLIPBOARD_INVERSEPOPPED_UPPOPULATE_POPUPPOPUP_MENUPREEDIT_CHANGEDREALIZERELEASEDRESIZEDROW_ACTIVATEDROW_DELETEDROW_HAS_CHILD_TOGGLEDROW_INSERTEDSCROLLSCROLL_BEGINSCROLL_CHILDSCROLL_ENDSCROLL_EVENTSELECTSELECTION_DONESHOWSHOW_HELPSIZE_ALLOCATESIZE_ALLOCATE_GTK4SKIN_NEEDEDSTART_INTERACTIVE_SEARCHstateSTATUS_ICON_POPUP_MENUstyleSTYLE_UPDATEDSWITCH_PAGETEST_COLLAPSE_ROWTEST_EXPAND_ROWTEXT_BUFFER_INSERT_TEXTTHEME_BACKGROUNDTOGGLEDUNMAPUNMAP_EVENTUNREALIZEVALUE_CHANGEDWINDOW_STATE_EVENTZERO_HEIGHTZERO_WIDTH

Constructor Summary

AccessConstructor and Description
public
Caret(Canvas
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
pack-priv void
pack-priv boolean
private void
drawInCellEditor(long window)

public Rectangle

Returns:

the receiver's bounding rectangle
getBounds
()

Returns a rectangle describing the receiver's size and location relative to its parent (or its display if its parent is null).

pack-priv Rectangle
public Font

Returns:

the receiver's font
getFont
()

Returns the font that the receiver will use to paint textual information.

public Image

Returns:

the receiver's image
getImage
()

Returns the image that the receiver will use to paint the caret.

public Point

Returns:

the receiver's location
getLocation
()

Returns a point describing the receiver's location relative to its parent (or its display if its parent is null).

pack-priv Point
public Canvas

Returns:

the receiver's parent
getParent
()

Returns the receiver's parent, which must be a Canvas.

public Point

Returns:

the receiver's size
getSize
()

Returns a point describing the receiver's size.

pack-priv Point
public boolean

Returns:

the receiver's visibility state
getVisible
()

Returns true if the receiver is visible, and false otherwise.

pack-priv boolean
pack-priv boolean
public boolean

Returns:

the receiver's visibility state
isVisible
()

Returns true if the receiver is visible and all of the receiver's ancestors are visible and false otherwise.

pack-priv void
pack-priv void
pack-priv void
public void
setBounds(int
the new x coordinate for the receiver
x
,
int
the new y coordinate for the receiver
y
,
int
the new width for the receiver
width
,
int
the new height for the receiver
height
)

Sets the receiver's size and location to the rectangular area specified by the arguments.

public void
setBounds(Rectangle
the new bounds for the receiver
rect
)

Sets the receiver's size and location to the rectangular area specified by the argument.

pack-priv void
setBoundsInPixels(int x, int y, int width, int height)

pack-priv void
pack-priv void
public void
setFont(Font
the new font (or null)
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.

public void
setImage(Image
the new image (or null)
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

public void
setLocation(int
the new x coordinate for the receiver
x
,
int
the new y coordinate for the receiver
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).

public void
setLocation(Point
the new location for the receiver
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).

pack-priv void
setLocationInPixels(int x, int y)

pack-priv void
public void
setSize(int
the new width for the receiver
width
,
int
the new height for the receiver
height
)

Sets the receiver's size to the point specified by the arguments.

public void
setSize(Point
the new extent for the receiver
size
)

Sets the receiver's size to the point specified by the argument.

pack-priv void
setSizeInPixels(int width, int height)

pack-priv void
public void
setVisible(boolean
the new visibility state
visible
)

Marks the receiver as visible if the argument is true, and marks it invisible otherwise.

pack-priv boolean
Inherited from org.eclipse.swt.widgets.Widget:
_addListeneraddDisposeListeneraddListenercellDataProccheckBitscheckOpencheckOrientationcheckParentcheckSubclasscheckWidgetconvertPangoFontDescriptionToCsscreateHandlecssHandlederegisterdestroyWidgetdisposedpiChangedenterMotionProcerrorfilterProcfiltersfixMnemonicfixMnemonicfixMnemonicfocusProcfontHeightgdk_event_freegdk_event_get_stategdk_event_get_surface_or_windowgdk_pointer_grabgdk_pointer_ungrabgdk_surface_get_sizegdk_window_get_sizeGdkSeatGrabPrepareFuncgesturePressReleaseProcgetDatagetDatagetDisplaygetListenersgetNamegetNameTextgetStylegtk3_show_helpgtk4_drawgtk4_enter_eventgtk4_focus_enter_eventgtk4_focus_leave_eventgtk4_focus_window_eventgtk4_key_press_eventgtk4_key_release_eventgtk4_leave_eventgtk4_motion_eventgtk4_scroll_eventgtk_activategtk_adjustment_getgtk_box_newgtk_box_pack_endgtk_box_set_child_packinggtk_button_press_eventgtk_button_release_eventgtk_cell_renderer_get_preferred_sizegtk_change_valuegtk_changedgtk_clickedgtk_close_requestgtk_commitgtk_configure_eventgtk_container_get_border_width_or_margingtk_container_set_border_widthgtk_create_menu_proxygtk_day_selectedgtk_day_selected_double_clickgtk_delete_eventgtk_delete_rangegtk_delete_textgtk_drawgtk_enter_notify_eventgtk_event_aftergtk_expand_collapse_cursor_rowgtk_focusgtk_focus_in_eventgtk_focus_out_eventgtk_gesture_press_eventgtk_gesture_release_eventgtk_grab_focusgtk_hidegtk_icon_releasegtk_inputgtk_insert_textgtk_key_press_eventgtk_key_release_eventgtk_leave_notify_eventgtk_mapgtk_map_eventgtk_menu_popped_upgtk_mnemonic_activategtk_month_changedgtk_motion_notify_eventgtk_move_focusgtk_outputgtk_populate_popupgtk_popup_menugtk_preedit_changedgtk_realizegtk_row_activatedgtk_row_has_child_toggledgtk_scroll_childgtk_scroll_eventgtk_selectgtk_selection_donegtk_showgtk_size_allocategtk_start_interactive_searchgtk_status_icon_popup_menugtk_style_updatedgtk_switch_pagegtk_test_collapse_rowgtk_test_expand_rowgtk_text_buffer_insert_textgtk_timergtk_toggledgtk_tree_view_column_cell_get_positiongtk_unmapgtk_unmap_eventgtk_unrealizegtk_value_changedgtk_widget_get_preferred_sizegtk_widget_get_surfacegtk_widget_get_windowgtk_widget_size_allocategtk_window_state_eventhookEventshookshoverProcisActiveisAutoDirectionisDisposedisListeningisValidSubclassisValidThreadkeyPressReleaseProcleaveProcmnemonicHitmnemonicMatchnotifyCreationTrackernotifyDisposalTrackernotifyListenersnotifyProcnotifyStatepaintSurfacepaintWindowpostEventpostEventregisterreleasereleaseChildrenreleaseHandleremoveDisposeListenerremoveListenerremoveListenerrendererGetPreferredWidthProcrendererRenderProcrendererSnapshotProcreskinreskinChildrenreskinWidgetscrollProcsendEventsendEventsendEventsendEventsendIMKeyEventsendKeyEventsendSelectionEventsendSelectionEventsetButtonStatesetDatasetDatasetFontDescriptionsetInputStatesetKeyStatesetLocationStatesetOrientationsetTabGroupFocussetTabItemFocussetToolTipTextshellMapProcsizeAllocateProcsizeRequestProcsnapshotToDrawtimerProctopHandletoStringtranslateTraversalwindowActiveProcwindowProcwindowProcwindowProcwindowProcwindowProc

Field Detail

blinkRateback to summary
pack-priv int blinkRate
DEFAULT_WIDTHback to summary
pack-priv static final int DEFAULT_WIDTH

Hides org.eclipse.swt.widgets.Widget.DEFAULT_WIDTH.

embeddedIntoback to summary
pack-priv Composite embeddedInto
fontback to summary
pack-priv Font font
heightback to summary
pack-priv int height
imageback to summary
pack-priv Image image
isShowingback to summary
pack-priv boolean isShowing
isVisibleback to summary
pack-priv boolean isVisible
parentback to summary
pack-priv Canvas parent
widthback to summary
pack-priv int width
xback to summary
pack-priv int x
yback to summary
pack-priv int y

Constructor Detail

Caretback to summary
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:Canvas

a composite control which will be the parent of the new instance (cannot be null)

style:int

the style of control to construct

Exceptions
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

blinkCaretback to summary
pack-priv boolean blinkCaret()
createWidgetback to summary
pack-priv void createWidget(int index)

Overrides org.eclipse.swt.widgets.Widget.createWidget.

Annotations
@Override
drawCaretback to summary
pack-priv boolean drawCaret()
drawInCellEditorback to summary
private void drawInCellEditor(long window)
getBoundsback to summary
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:Rectangle

the receiver's bounding rectangle

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getBoundsInPixelsback to summary
pack-priv Rectangle getBoundsInPixels()
getFontback to summary
public Font getFont()

Returns the font that the receiver will use to paint textual information.

Returns:Font

the receiver's font

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getImageback to summary
public Image getImage()

Returns the image that the receiver will use to paint the caret.

Returns:Image

the receiver's image

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getLocationback to summary
public Point getLocation()

Returns a point describing the receiver's location relative to its parent (or its display if its parent is null).

Returns:Point

the receiver's location

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getLocationInPixelsback to summary
pack-priv Point getLocationInPixels()
getParentback to summary
public Canvas getParent()

Returns the receiver's parent, which must be a Canvas.

Returns:Canvas

the receiver's parent

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getSizeback to summary
public Point getSize()

Returns a point describing the receiver's size.

Returns:Point

the receiver's size

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getSizeInPixelsback to summary
pack-priv Point getSizeInPixels()
getVisibleback to summary
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:boolean

the receiver's visibility state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
hideCaretback to summary
pack-priv boolean hideCaret()
isFocusCaretback to summary
pack-priv boolean isFocusCaret()
isVisibleback to summary
public boolean isVisible()

Returns true if the receiver is visible and all of the receiver's ancestors are visible and false otherwise.

Returns:boolean

the receiver's visibility state

Exceptions
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
killFocusback to summary
pack-priv void killFocus()
releaseParentback to summary
pack-priv void releaseParent()

Overrides org.eclipse.swt.widgets.Widget.releaseParent.

Annotations
@Override
releaseWidgetback to summary
pack-priv void releaseWidget()

Overrides org.eclipse.swt.widgets.Widget.releaseWidget.

Annotations
@Override
setBoundsback to summary
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:int

the new x coordinate for the receiver

y:int

the new y coordinate for the receiver

width:int

the new width for the receiver

height:int

the new height for the receiver

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setBoundsback to summary
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:Rectangle

the new bounds for the receiver

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setBoundsInPixelsback to summary
pack-priv void setBoundsInPixels(int x, int y, int width, int height)
setBoundsInPixelsback to summary
pack-priv void setBoundsInPixels(Rectangle rect)
setFocusback to summary
pack-priv void setFocus()
setFontback to summary
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:Font

the new font (or null)

Exceptions
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
setImageback to summary
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:Image

the new image (or null)

Exceptions
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
setLocationback to summary
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:int

the new x coordinate for the receiver

y:int

the new y coordinate for the receiver

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setLocationback to summary
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:Point

the new location for the receiver

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setLocationInPixelsback to summary
pack-priv void setLocationInPixels(int x, int y)
setLocationInPixelsback to summary
pack-priv void setLocationInPixels(Point location)
setSizeback to summary
public void setSize(int width, int height)

Sets the receiver's size to the point specified by the arguments.

Parameters
width:int

the new width for the receiver

height:int

the new height for the receiver

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setSizeback to summary
public void setSize(Point size)

Sets the receiver's size to the point specified by the argument.

Parameters
size:Point

the new extent for the receiver

Exceptions
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
setSizeInPixelsback to summary
pack-priv void setSizeInPixels(int width, int height)
setSizeInPixelsback to summary
pack-priv void setSizeInPixels(Point size)
setVisibleback to summary
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:boolean

the new visibility state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
showCaretback to summary
pack-priv boolean showCaret()