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

public abstract Class Widget

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.swt.dnd.DragSource, org.eclipse.swt.dnd.DropTarget, org.eclipse.swt.widgets.Caret, org.eclipse.swt.widgets.Control, org.eclipse.swt.widgets.IME, org.eclipse.swt.widgets.Item, org.eclipse.swt.widgets.Menu, org.eclipse.swt.widgets.ScrollBar, org.eclipse.swt.widgets.TaskBar, org.eclipse.swt.widgets.ToolTip, org.eclipse.swt.widgets.Tracker, org.eclipse.swt.widgets.Tray
Imports
java.util.*, org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

This class is the abstract superclass of all user interface objects. Widgets are created, disposed and issue notification to listeners when events occur which affect them.
Styles:
(none)
Events:
Dispose

Important Note

This class is intended to be subclassed only within the SWT implementation. However, it has not been marked final to allow those outside of the SWT development team to implement patched versions of the class in order to get around specific limitations in advance of when those limitations can be addressed by the team. Any class built using subclassing to access the internals of this class will likely fail to compile or run between releases and may be strongly platform specific. Subclassing should not be attempted without an intimate and detailed understanding of the workings of the hierarchy. No support is provided for user-written classes which are implemented as subclasses of this class.

See Also
checkSubclass, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv Object
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv Display
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv EventTable
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static Callback
pack-priv static final int
pack-priv static final int
pack-priv static final int
public long
handle

the handle to the OS resource (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final String
pack-priv static final String
pack-priv static final String
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv int
pack-priv static final int
pack-priv int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
pack-priv
Widget()

Prevents uninitialized instances from being created outside the package.

public
Widget(Widget
a widget which will be the parent of the new instance (cannot be null)
parent
,
int
the style of widget 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 void
_addListener(int eventType, Listener listener)

public void
addDisposeListener(DisposeListener
the listener which should be notified when the receiver is disposed
listener
)

Adds the listener to the collection of listeners who will be notified when the widget is disposed.

public void
addListener(int
the type of event to listen for
eventType
,
Listener
the listener which should be notified when the event occurs
listener
)

Adds the listener to the collection of listeners who will be notified when an event of the given type occurs.

pack-priv long
cellDataProc(long tree_column, long cell, long tree_model, long iter, long data)

pack-priv static int
checkBits(int style, int int0, int int1, int int2, int int3, int int4, int int5)

pack-priv void
pack-priv void
pack-priv void
checkParent(Widget parent)

Throws an exception if the specified widget can not be used as a parent for the receiver.

protected void
checkSubclass()

Checks that this class can be subclassed.

protected void
checkWidget()

Throws an SWTException if the receiver can not be accessed by the caller.

pack-priv String
convertPangoFontDescriptionToCss(long fontDescription)

pack-priv void
createHandle(int index)

pack-priv void
createWidget(int index)

pack-priv long
pack-priv void
pack-priv void
public void
dispose()

Disposes of the operating system resources associated with the receiver and all its descendants.

pack-priv long
dpiChanged(long object, long arg0)

pack-priv void
enterMotionProc(long controller, double x, double y, long user_data)

pack-priv void
error(int code)

pack-priv long
filterProc(long xEvent, long gdkEvent, long data2)

pack-priv boolean
filters(int eventType)

pack-priv char[]
pack-priv char[]
fixMnemonic(String string, boolean replace)

pack-priv char[]
fixMnemonic(String string, boolean replace, boolean removeAppended)

pack-priv void
focusProc(long controller, long user_data)

pack-priv int
fontHeight(long font, long widgetHandle)

pack-priv void
gdk_event_free(long
the event to be freed
event
)

GTK4 does not hand out copies of events anymore, only references.

pack-priv int

Returns:

the keymask to be used with constants like OS.GDK_SHIFT_MASK / OS.GDK_CONTROL_MASK / OS.GDK_MOD1_MASK etc..
gdk_event_get_state
(long
pointer to the GdkEvent.
event
)

Wrapper function for gdk_event_get_state()

pack-priv long

Returns:

the GdkWindow or GdkSurface associated with the event
gdk_event_get_surface_or_window
(long
the event whose window or surface to fetch
event
)

Wrapper function for gdk_event_get_surface() on GTK4, and gdk_event_get_window() on GTK3.

pack-priv int
gdk_pointer_grab(long gdkResource, int grab_ownership, boolean owner_events, int event_mask, long confine_to, long cursor, int time_)

pack-priv void
gdk_pointer_ungrab(long gdkResource, int time_)

pack-priv void
gdk_surface_get_size(long surface, int[] width, int[] height)

pack-priv void
gdk_window_get_size(long drawable, int[] width, int[] height)

pack-priv static long
GdkSeatGrabPrepareFunc(long gdkSeat, long gdkResource, long userData_gdkResource)

pack-priv void
gesturePressReleaseProc(long gesture, int n_press, double x, double y, long user_data)

public Object

Returns:

the widget data
getData
()

Returns the application defined widget data associated with the receiver, or null if it has not been set.

public Object

Returns:

the value of the property or null if it has not been set
getData
(String
the name of the property
key
)

Returns the application defined property of the receiver with the specified name, or null if it has not been set.

public Display

Returns:

the receiver's display
getDisplay
()

Returns the Display that is associated with the receiver.

public Listener[]

Returns:

an array of listeners that will be notified when the event occurs
getListeners
(int
the type of event to listen for
eventType
)

Returns an array of listeners who will be notified when an event of the given type occurs.

pack-priv String
pack-priv String
public int

Returns:

the style bits
getStyle
()

Returns the receiver's style information.

pack-priv long
gtk3_show_help(long widget, long helpType)

pack-priv void
gtk4_draw(long widget, long cairo, Rectangle bounds)

pack-priv void
gtk4_enter_event(long
the corresponding controller responsible for capturing the event
controller
,
double
x coordinate of pointer location
x
,
double
y coordinate of pointer location
y
,
long
the GdkEvent captured
event
)

pack-priv void
gtk4_focus_enter_event(long
the corresponding controller responsible for capturing the event
controller
,
long
the GdkEvent captured
event
)

pack-priv void
gtk4_focus_leave_event(long
the corresponding controller responsible for capturing the event
controller
,
long
the GdkEvent captured
event
)

pack-priv void
gtk4_focus_window_event(long
the handle of the window that caused the event
handle
,
long
the type of event, should be FocusIn or FocusOut
event
)

pack-priv boolean

Returns:

TRUE if the event has been fully/properly handled, otherwise FALSE
gtk4_key_press_event
(long
the corresponding controller responsible for capturing the event
controller
,
int
the pressed key
keyval
,
int
raw code of the pressed key
keycode
,
int
the bitmask, representing the state of the modifier keys and pointer buttons
state
,
long
the GdkEvent captured
event
)

pack-priv void
gtk4_key_release_event(long
the corresponding controller responsible for capturing the event
controller
,
int
the released key
keyval
,
int
raw code of the released key
keycode
,
int
the bitmask, representing the state of the modifier keys and pointer buttons
state
,
long
the GdkEvent captured
event
)

pack-priv void
gtk4_leave_event(long
the corresponding controller responsible for capturing the event
controller
,
long
the GdkEvent captured
event
)

pack-priv void
gtk4_motion_event(long
the corresponding controller responsible for capturing the event
controller
,
double
the x coordinate
x
,
double
the y coordinate
y
,
long
the GdkEvent captured
event
)

pack-priv boolean

Returns:

TRUE if the scroll event was handled, FALSE otherwise
gtk4_scroll_event
(long
the corresponding controller responsible for capturing the event
controller
,
double
x delta
dx
,
double
y delta
dy
,
long
the GdkEvent captured
event
)

pack-priv long
gtk_activate(long widget)

pack-priv void
gtk_adjustment_get(long adjustmentHandle, GtkAdjustment adjustment)

pack-priv long
gtk_box_new(int orientation, boolean homogeneous, int spacing)

pack-priv void
gtk_box_pack_end(long box, long child, boolean expand, boolean fill, int padding)

pack-priv void
gtk_box_set_child_packing(long box, long child, boolean expand, boolean fill, int padding, int pack_type)

pack-priv long
gtk_button_press_event(long widget, long event)

pack-priv long
gtk_button_release_event(long widget, long event)

pack-priv void
gtk_cell_renderer_get_preferred_size(long cell, long widget, int[] width, int[] height)

pack-priv boolean
gtk_change_value(long widget, int scroll, double value, long user_data)

pack-priv long
gtk_changed(long widget)

pack-priv long
gtk_clicked(long widget)

pack-priv long
gtk_close_request(long widget)

pack-priv long
gtk_commit(long imcontext, long text)

pack-priv long
gtk_configure_event(long widget, long event)

pack-priv int

Returns:

amount of space around the outside of the container.
gtk_container_get_border_width_or_margin
(long handle)

Retrieves the amount of space around the outside of the container.

pack-priv void
gtk_container_set_border_width(long handle, int border_width)

Sets the border width of the container to all sides of the container.

pack-priv long
gtk_create_menu_proxy(long widget)

pack-priv long
gtk_day_selected(long widget)

pack-priv long
pack-priv long
gtk_delete_event(long widget, long event)

pack-priv long
gtk_delete_range(long widget, long iter1, long iter2)

pack-priv long
gtk_delete_text(long widget, long start_pos, long end_pos)

pack-priv long
gtk_draw(long widget, long cairo)

pack-priv long
gtk_enter_notify_event(long widget, long event)

pack-priv long
gtk_event_after(long widget, long event)

pack-priv long
gtk_expand_collapse_cursor_row(long widget, long logical, long expand, long open_all)

pack-priv long
gtk_focus(long widget, long event)

pack-priv long
gtk_focus_in_event(long widget, long event)

pack-priv long
gtk_focus_out_event(long widget, long event)

pack-priv void
gtk_gesture_press_event(long
the corresponding controller responsible for capturing the event
gesture
,
int
how many touch/button presses happened with this one
n_press
,
double
the x coordinate, in widget allocation coordinates
x
,
double
the y coordinate, in widget allocation coordinates
y
,
long
the GdkEvent captured
event
)

pack-priv void
gtk_gesture_release_event(long
the corresponding controller responsible for capturing the event
gesture
,
int
how many touch/button presses happened with this one
n_press
,
double
the x coordinate, in widget allocation coordinates
x
,
double
the y coordinate, in widget allocation coordinates
y
,
long
the GdkEvent captured
event
)

pack-priv long
gtk_grab_focus(long widget)

pack-priv long
gtk_hide(long widget)

pack-priv long
gtk_icon_release(long widget, long icon_pos, long event)

pack-priv long
gtk_input(long widget, long arg1)

pack-priv long
gtk_insert_text(long widget, long new_text, long new_text_length, long position)

pack-priv long
gtk_key_press_event(long widget, long event)

pack-priv long
gtk_key_release_event(long widget, long event)

pack-priv long
gtk_leave_notify_event(long widget, long event)

pack-priv long
gtk_map(long widget)

pack-priv long
gtk_map_event(long widget, long event)

pack-priv long
gtk_menu_popped_up(long
the memory address of the menu which was popped up
widget
,
long
a pointer to the GdkRectangle containing the flipped location and size of the menu
flipped_rect
,
long
a pointer to the GdkRectangle containing the final (after all internal adjustments) location and size of the menu
final_rect
,
long
a boolean flag indicating whether the menu has been inverted along the X-axis
flipped_x
,
long
a boolean flag indicating whether the menu has been inverted along the Y-axis
flipped_y
)

GTK3.22+ has API which allows clients of GTK to connect a menu to the "popped-up" signal.

pack-priv long
gtk_mnemonic_activate(long widget, long arg1)

pack-priv long
gtk_month_changed(long widget)

pack-priv long
gtk_motion_notify_event(long widget, long event)

pack-priv long
gtk_move_focus(long widget, long event)

pack-priv long
gtk_output(long widget)

pack-priv long
gtk_populate_popup(long widget, long menu)

pack-priv long
gtk_popup_menu(long widget)

pack-priv long
gtk_preedit_changed(long imcontext)

pack-priv long
gtk_realize(long widget)

pack-priv long
gtk_row_activated(long tree, long path, long column)

pack-priv long
gtk_row_has_child_toggled(long model, long path, long iter)

pack-priv long
gtk_scroll_child(long widget, long scrollType, long horizontal)

pack-priv long
gtk_scroll_event(long widget, long event)

pack-priv long
gtk_select(long item)

pack-priv long
gtk_selection_done(long menushell)

pack-priv long
gtk_show(long widget)

pack-priv long
gtk_size_allocate(long widget, long allocation)

pack-priv long
pack-priv long
gtk_status_icon_popup_menu(long handle, long button, long activate_time)

pack-priv long
gtk_style_updated(long widget)

pack-priv long
gtk_switch_page(long notebook, long page, int page_num)

pack-priv long
gtk_test_collapse_row(long tree, long iter, long path)

pack-priv long
gtk_test_expand_row(long tree, long iter, long path)

pack-priv long
gtk_text_buffer_insert_text(long widget, long iter, long text, long length)

pack-priv long
pack-priv long
gtk_toggled(long renderer, long pathStr)

pack-priv boolean
gtk_tree_view_column_cell_get_position(long column, long cell_renderer, int[] start_pos, int[] width)

pack-priv long
gtk_unmap(long widget)

pack-priv long
gtk_unmap_event(long widget, long event)

pack-priv long
gtk_unrealize(long widget)

pack-priv long
gtk_value_changed(long range)

pack-priv void
pack-priv long
pack-priv long
gtk_widget_get_window(long widget)

pack-priv void
gtk_widget_size_allocate(long widget, GtkAllocation allocation, int baseline)

pack-priv long
gtk_window_state_event(long widget, long event)

pack-priv void
pack-priv boolean
hooks(int eventType)

pack-priv long
hoverProc(long widget)

pack-priv boolean
public boolean

Returns:

true when the widget has auto direction and false otherwise
isAutoDirection
()

Returns true if the widget has auto text direction, and false otherwise.

public boolean

Returns:

true when the widget is disposed and false otherwise
isDisposed
()

Returns true if the widget has been disposed, and false otherwise.

public boolean

Returns:

true if the event is hooked
isListening
(int
the type of event
eventType
)

Returns true if there are any listeners for the specified event type associated with the receiver, and false otherwise.

pack-priv boolean
pack-priv boolean
pack-priv boolean
keyPressReleaseProc(long controller, int keyval, int keycode, int state, long user_data)

pack-priv void
leaveProc(long controller, long handle, long user_data)

pack-priv boolean
mnemonicHit(long mnemonicHandle, char key)

pack-priv boolean
mnemonicMatch(long mnemonicHandle, char key)

pack-priv void
pack-priv void
public void
notifyListeners(int
the type of event which has occurred
eventType
,
Event
the event data
event
)

Notifies all of the receiver's listeners for events of the given type that one such event has occurred by invoking their handleEvent() method.

pack-priv long
notifyProc(long object, long arg0, long user_data)

pack-priv long
notifyState(long object, long argo0)

pack-priv long
pack-priv long
pack-priv void
postEvent(int eventType)

pack-priv void
postEvent(int eventType, Event event)

pack-priv void
pack-priv void
release(boolean destroy)

pack-priv void
releaseChildren(boolean destroy)

pack-priv void
pack-priv void
pack-priv void
public void
removeDisposeListener(DisposeListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the widget is disposed.

public void
removeListener(int
the type of event to listen for
eventType
,
Listener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.

protected void
removeListener(int
the type of event to listen for
eventType
,
SWTEventListener
the listener which should no longer be notified
handler
)

Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.

pack-priv long
rendererGetPreferredWidthProc(long cell, long handle, long minimun_size, long natural_size)

pack-priv long
rendererRenderProc(long cell, long cr, long handle, long background_area, long cell_area, long flags)

pack-priv long
rendererSnapshotProc(long cell, long snapshot, long handle, long background_area, long cell_area, long flags)

public void
reskin(int
the flags specifying how to reskin
flags
)

Marks the widget to be skinned.

pack-priv void
reskinChildren(int flags)

pack-priv void
pack-priv boolean
scrollProc(long controller, double dx, double dy, long user_data)

pack-priv void
pack-priv void
sendEvent(int eventType)

pack-priv void
sendEvent(int eventType, Event event)

pack-priv void
sendEvent(int eventType, Event event, boolean send)

pack-priv char[]
sendIMKeyEvent(int type, long event, char[] chars)

pack-priv boolean
sendKeyEvent(int type, long event)

pack-priv void
sendSelectionEvent(int eventType)

pack-priv void
sendSelectionEvent(int eventType, Event event, boolean send)

pack-priv void
setButtonState(Event event, int eventButton)

public void
setData(Object
the widget data
data
)

Sets the application defined widget data associated with the receiver to be the argument.

public void
setData(String
the name of the property
key
,
Object
the new value for the property
value
)

Sets the application defined property of the receiver with the specified name to the given value.

pack-priv void
setFontDescription(long widget, long
Font description in the form of PangoFontDescription*. This pointer will never be used by GTK after calling this function, so it's safe to free it as soon as the function completes.
fontDescription
)

pack-priv boolean
setInputState(Event event, int state)

pack-priv boolean
setKeyState(Event javaEvent, long event)

On Linux, the most common way to handle keyboard input is XKB.

pack-priv void
setLocationState(Event event, long eventPtr)

pack-priv void
setOrientation(boolean create)

pack-priv boolean
setTabGroupFocus(boolean next)

pack-priv boolean
setTabItemFocus(boolean next)

pack-priv void
setToolTipText(long tipWidget, String string)

pack-priv long
shellMapProc(long handle, long arg0, long user_data)

pack-priv long
sizeAllocateProc(long handle, long arg0, long user_data)

pack-priv long
sizeRequestProc(long handle, long arg0, long user_data)

pack-priv void
snapshotToDraw(long
the widget receiving the snapshot
handle
,
long
the actual GtkSnapshot
snapshot
)

Converts an incoming snapshot into a gtk_draw() call, complete with a Cairo context.

pack-priv long
timerProc(long widget)

pack-priv long
public String

Returns:

a string representation of the receiver
toString
()

Overrides java.lang.Object.toString.

Returns a string containing a concise, human-readable description of the receiver.
pack-priv boolean
translateTraversal(int event)

pack-priv void
windowActiveProc(long handle, long user_data)

pack-priv long
windowProc(long handle, long user_data)

pack-priv long
windowProc(long handle, long arg0, long user_data)

pack-priv long
windowProc(long handle, long arg0, long arg1, long user_data)

pack-priv long
windowProc(long handle, long arg0, long arg1, long arg2, long user_data)

pack-priv long
windowProc(long handle, long arg0, long arg1, long arg2, long arg3, long user_data)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait