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

public Class Link

extends Control
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.accessibility.*, 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.*

Instances of this class represent a selectable user interface object that displays a text with links.
Styles:
(none)
Events:
Selection

Important Note

This class is not intended to be subclassed.

Since
3.1
See Also
Link snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv Color
pack-priv int
focusIndex

Index of the currently focused link in the text.

pack-priv String[]
pack-priv TextLayout
pack-priv Color
pack-priv int[]
pack-priv Point[]
pack-priv Point
pack-priv String
Inherited from org.eclipse.swt.widgets.Control:
accessibleautoScalebackgroundAlphabackgroundImagecachedNoBackgroundcheckScaleFactorcssBackgroundcssForegroundcursorDISABLE_EMOJIdragDetectionQueuedragGesturedrawCountdrawRegionenableWindoweventRegionfirstFixedHandlefixedHandlefontgestureBegingestureEndgestureRotationgestureSwipegestureZoomkeyControllerlabelRelationlastInputlayoutDatamenumouseDownpanGestureparentproviderredrawWindowregionregionHandlerotateGesturetoolTipTextzoomGesture

Constructor Summary

AccessConstructor and Description

Method Summary

Modifier and TypeMethod and Description
public void
addSelectionListener(SelectionListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

pack-priv Point
computeSizeInPixels(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Control.computeSizeInPixels.

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public Color

Returns:

the receiver's link foreground color.
getLinkForeground
()

Returns the link foreground color.

pack-priv String
pack-priv Rectangle[]
getRectanglesInPixels(int linkIndex)

public String

Returns:

the receiver's text
getText
()

Returns the receiver's text, which will be an empty string if it has never been set.

pack-priv boolean
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
)

Overrides org.eclipse.swt.widgets.Control.gtk4_key_press_event.

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

Overrides org.eclipse.swt.widgets.Control.gtk_draw.

pack-priv long
pack-priv long
pack-priv long
pack-priv boolean
pack-priv void
pack-priv boolean
pack-priv boolean
pack-priv String
parse(String string)

pack-priv int
parseMnemonics(char[] buffer, int start, int end, StringBuilder result)

pack-priv void
public void
removeSelectionListener(SelectionListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the control is selected by the user.

pack-priv int
setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Control.setBounds.

pack-priv void
public void
setLinkForeground(Color
the new color (or null)
color
)

Sets the link foreground color to the color specified by the argument, or to the default system color for the link if the argument is null.

pack-priv void
public void
setText(String
the new text
string
)

Sets the receiver's text.

pack-priv void
pack-priv void
pack-priv int
Inherited from org.eclipse.swt.widgets.Control:
_getAccessible_getShelladdControlListeneraddDragDetectListeneraddFocusListeneraddGestureListeneraddHelpListeneraddKeyListeneraddMenuDetectListeneraddMouseListeneraddMouseMoveListeneraddMouseTrackListeneraddMouseWheelListeneraddPaintListeneraddRelationaddTouchListeneraddTraverseListeneradjustChildClippingcairoClipRegioncairoCopyRegioncairoDisposeRegioncheckBackgroundcheckBordercheckBufferedcheckMirroredcheckSubwindowcleanupEnableWindowcomputeNativeSizecomputeSizecomputeSizecomputeSizeInPixelscomputeTabGroupcomputeTabListcomputeTabRootcontainedInRegiondefaultBackgrounddefaultFontderegisterdestroyWidgetdragDetectdragDetectdragDetectdragDetectdrawBackgrounddrawGripperenterExitHandleeventHandleeventSurfaceeventWindowfilterKeyfindBackgroundControlfindMenusfixChildrenfixFocusfixGdkEventTypeValuesfixModalfixParentGdkResourcefixStyleflushQueueOnDndfocusHandlefontHandleforceFocusforceFocusforceResizegestureBeginProcgestureEndProcgestureHandlegetAccessiblegetBackgroundgetBackgroundGdkRGBAgetBackgroundImagegetBaseGdkRGBAgetBgGdkRGBAgetBorderWidthgetBorderWidthInPixelsgetBoundsgetBoundsInPixelsgetClientWidthgetContextBackgroundGdkRGBAgetContextColorGdkRGBAgetControlgetControlOrigingetCursorgetDragDetectgetEnabledgetFontgetFontDescriptiongetForegroundgetForegroundGdkRGBAgetIMCaretPosgetLayoutDatagetLocationgetLocationInPixelsgetMenugetMonitorgetOrientationgetParentgetPathgetRegiongetShellgetSizegetSizeInPixelsgetSurfaceOrigingetTextDirectiongetThicknessgetToolTipTextgetTouchEnabledgetVisiblegetWindowOrigingtk3_show_helpgtk4_drawgtk4_enter_eventgtk4_focus_enter_eventgtk4_focus_leave_eventgtk4_focus_window_eventgtk4_key_release_eventgtk4_leave_eventgtk4_motion_eventgtk4_scroll_eventgtk_button_press_eventgtk_commitgtk_css_provider_load_from_cssgtk_enter_notify_eventgtk_focusgtk_focus_in_eventgtk_focus_out_eventgtk_gesture_press_eventgtk_gesture_release_eventgtk_key_release_eventgtk_label_set_aligngtk_leave_notify_eventgtk_mnemonic_activategtk_popup_menugtk_preedit_changedgtk_realizegtk_scroll_eventgtk_style_context_get_bordergtk_style_context_get_paddinggtk_style_updatedgtk_unrealizegtk_widget_reparentgtk_widget_set_alignhasFocushookEventshoverProcimHandleinternal_dispose_GCinternal_new_GCisActiveisAutoScalableisDescribedByLabelisEnabledisFocusAncestorisFocusControlisFocusHandleisReparentableisShowingisTabGroupisTabItemisVisiblemagnifyProcmarkLayoutmenuShellmoveAbovemoveBelowmoveChildrenmoveHandlemustBeVisibleOnInitBoundspackpackpaintHandlepaintSurfacepaintWindowprintprintWidgetprintWindowredrawredrawredrawredrawChildrenredrawInPixelsredrawWidgetregisterreleasereleaseHandlereleaseParentremoveControlListenerremoveDragDetectListenerremoveFocusListenerremoveGestureListenerremoveHelpListenerremoveKeyListenerremoveMenuDetectListenerremoveMouseListenerremoveMouseMoveListenerremoveMouseTrackListenerremoveMouseWheelListenerremovePaintListenerremoveRelationremoveTouchListenerremoveTraverseListenerrequestLayoutresizeCalculationsGTK3resizeHandlerestackWindowrotateProcsendDragEventsendFocusEventsendGestureEventsendGestureEventsendGestureEventsendHelpEventsendLeaveNotifysendMouseEventsendMouseEventsetBackgroundsetBackgroundsetBackgroundGdkRGBAsetBackgroundGdkRGBAsetBackgroundGdkRGBAsetBackgroundImagesetBackgroundSurfacesetBoundssetBoundssetBoundsInPixelssetBoundsInPixelssetCapturesetCursorsetCursorsetDragDetectsetEnabledsetFocussetFontsetForegroundsetForegroundGdkRGBAsetForegroundGdkRGBAsetInitialBoundssetLayoutDatasetLocationsetLocationsetLocationInPixelssetLocationInPixelssetMenusetOrientationsetParentsetParentBackgroundsetParentGdkResourcesetRadioSelectionsetRedrawsetRegionsetRelationssetSizesetSizesetSizeInPixelssetSizeInPixelssetTabItemFocussetTextDirectionsetToolTipTextsetToolTipTextsetTouchEnabledsetVisiblesetWidgetBackgroundsetZOrdersetZOrdershowMenushowMenusortswipeProctoControltoControltoDisplaytoDisplaytoDisplayInPixelstoDisplayInPixelstopHandletranslateMnemonictranslateMnemonictranslateTraversaltraversetraversetraversetraversetraversetraverseEscapetraverseGrouptraverseItemtraverseMnemonictraversePagetraverseReturnupdateupdateupdateBackgroundModeupdateLayoutwantDragDropDetectionwindowProc

Field Detail

disabledColorback to summary
pack-priv Color disabledColor
focusIndexback to summary
pack-priv int focusIndex

Index of the currently focused link in the text. Equals -1, if the text has not been set through setText

idsback to summary
pack-priv String[] ids
layoutback to summary
pack-priv TextLayout layout
linkColorback to summary
pack-priv Color linkColor
mnemonicsback to summary
pack-priv int[] mnemonics
offsetsback to summary
pack-priv Point[] offsets
selectionback to summary
pack-priv Point selection
textback to summary
pack-priv String text

Constructor Detail

Method Detail

addSelectionListenerback to summary
public void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

widgetSelected is called when the control is selected by the user. widgetDefaultSelected is not called.

Parameters
listener:SelectionListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener 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
See Also
SelectionListener, removeSelectionListener, SelectionEvent
computeSizeInPixelsback to summary
pack-priv Point computeSizeInPixels(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Control.computeSizeInPixels.

Annotations
@Override
createHandleback to summary
pack-priv void createHandle(int index)

Overrides org.eclipse.swt.widgets.Widget.createHandle.

Annotations
@Override
createWidgetback to summary
pack-priv void createWidget(int index)

Overrides org.eclipse.swt.widgets.Control.createWidget.

Annotations
@Override
drawWidgetback to summary
pack-priv void drawWidget(GC gc)

Overrides org.eclipse.swt.widgets.Control.drawWidget.

Annotations
@Override
enableWidgetback to summary
pack-priv void enableWidget(boolean enabled)

Overrides org.eclipse.swt.widgets.Control.enableWidget.

Annotations
@Override
fixStyleback to summary
pack-priv void fixStyle()

Overrides org.eclipse.swt.widgets.Control.fixStyle.

Annotations
@Override
getLinkForegroundback to summary
public Color getLinkForeground()

Returns the link foreground color.

Returns:Color

the receiver's link foreground color.

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
Since
3.105
getNameTextback to summary
pack-priv String getNameText()

Overrides org.eclipse.swt.widgets.Widget.getNameText.

Annotations
@Override
getRectanglesInPixelsback to summary
pack-priv Rectangle[] getRectanglesInPixels(int linkIndex)
getTextback to summary
public String getText()

Returns the receiver's text, which will be an empty string if it has never been set.

Returns:String

the receiver's text

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
gtk4_key_press_eventback to summary
pack-priv boolean gtk4_key_press_event(long controller, int keyval, int keycode, int state, long event)

Overrides org.eclipse.swt.widgets.Control.gtk4_key_press_event.

Parameters
controller:long

Doc from org.eclipse.swt.widgets.Widget.gtk4_key_press_event.

the corresponding controller responsible for capturing the event

keyval:int

Doc from org.eclipse.swt.widgets.Widget.gtk4_key_press_event.

the pressed key

keycode:int

Doc from org.eclipse.swt.widgets.Widget.gtk4_key_press_event.

raw code of the pressed key

state:int

Doc from org.eclipse.swt.widgets.Widget.gtk4_key_press_event.

the bitmask, representing the state of the modifier keys and pointer buttons

event:long

Doc from org.eclipse.swt.widgets.Widget.gtk4_key_press_event.

the GdkEvent captured

Returns:boolean

Doc from org.eclipse.swt.widgets.Widget.gtk4_key_press_event.

TRUE if the event has been fully/properly handled, otherwise FALSE

Annotations
@Override
gtk_button_press_eventback to summary
pack-priv long gtk_button_press_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Control.gtk_button_press_event.

Annotations
@Override
gtk_button_release_eventback to summary
pack-priv long gtk_button_release_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Control.gtk_button_release_event.

Annotations
@Override
gtk_drawback to summary
pack-priv long gtk_draw(long widget, long cairo)

Overrides org.eclipse.swt.widgets.Control.gtk_draw.

Annotations
@Override
gtk_event_afterback to summary
pack-priv long gtk_event_after(long widget, long gdkEvent)

Overrides org.eclipse.swt.widgets.Control.gtk_event_after.

Annotations
@Override
gtk_key_press_eventback to summary
pack-priv long gtk_key_press_event(long widget, long eventPtr)

Overrides org.eclipse.swt.widgets.Control.gtk_key_press_event.

Annotations
@Override
gtk_motion_notify_eventback to summary
pack-priv long gtk_motion_notify_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Control.gtk_motion_notify_event.

Annotations
@Override
hooksPaintback to summary
pack-priv boolean hooksPaint()

Overrides org.eclipse.swt.widgets.Control.hooksPaint.

Annotations
@Override
initAccessibleback to summary
pack-priv void initAccessible()
mnemonicHitback to summary
pack-priv boolean mnemonicHit(char key)

Overrides org.eclipse.swt.widgets.Control.mnemonicHit.

Annotations
@Override
mnemonicMatchback to summary
pack-priv boolean mnemonicMatch(char key)

Overrides org.eclipse.swt.widgets.Control.mnemonicMatch.

Annotations
@Override
parseback to summary
pack-priv String parse(String string)
parseMnemonicsback to summary
pack-priv int parseMnemonics(char[] buffer, int start, int end, StringBuilder result)
releaseWidgetback to summary
pack-priv void releaseWidget()

Overrides org.eclipse.swt.widgets.Control.releaseWidget.

Annotations
@Override
removeSelectionListenerback to summary
public void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners who will be notified when the control is selected by the user.

Parameters
listener:SelectionListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener 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
See Also
SelectionListener, addSelectionListener
setBoundsback to summary
pack-priv int setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Control.setBounds.

Annotations
@Override
setFontDescriptionback to summary
pack-priv void setFontDescription(long font)

Overrides org.eclipse.swt.widgets.Control.setFontDescription.

Annotations
@Override
setLinkForegroundback to summary
public void setLinkForeground(Color color)

Sets the link foreground color to the color specified by the argument, or to the default system color for the link if the argument is null.

Note

This operation is a hint and may be overridden by the platform.

Parameters
color:Color

the new color (or null)

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the argument 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
Since
3.105
setOrientationback to summary
pack-priv void setOrientation(boolean create)

Overrides org.eclipse.swt.widgets.Control.setOrientation.

Annotations
@Override
setTextback to summary
public void setText(String string)

Sets the receiver's text.

The string can contain both regular text and hyperlinks. A hyperlink is delimited by an anchor tag, <a> and </a>. Within an anchor, a single HREF attribute is supported. When a hyperlink is selected, the text field of the selection event contains either the text of the hyperlink or the value of its HREF, if one was specified. In the rare case of identical hyperlinks within the same string, the HREF attribute can be used to distinguish between them. The string may include the mnemonic character and line delimiters. The only delimiter the HREF attribute supports is the quotation mark ("). Text containing angle-bracket characters < or > may be escaped using \\, however this operation is a hint and varies from platform to platform.

Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. The receiver can have a mnemonic in the text preceding each link. When the user presses a key sequence that matches the mnemonic, focus is assigned to the link that follows the text. Mnemonics in links and in the trailing text are ignored. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.

Parameters
string:String

the new text

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the text 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
showWidgetback to summary
pack-priv void showWidget()

Overrides org.eclipse.swt.widgets.Control.showWidget.

Annotations
@Override
styleLinkPartsback to summary
pack-priv void styleLinkParts()
traversalCodeback to summary
pack-priv int traversalCode(int key, long event)

Overrides org.eclipse.swt.widgets.Control.traversalCode.

Annotations
@Override