Links
are
selectable UI components that can contain regular text and hyperlinks. Clicking
a hyperlink inside a Link
triggers a SelectionEvent
containing
either the text of the hyperlink or its HREF
value.
Figure: Link with a hyperlink
To set the text and hyperlinks for a Link
, use the setText
method.
To capture and process SelectionEvents
from the Link
,
implement SelectionListener
for handling the events, and register the SelectionListener
for
the Link
by using the addSelectionListener
method.
The following code snippet shows you how to create a simple Link
with
a predefined link text:
// Create a Link with borders Link link = new Link(parent, SWT.BORDER); // Set the Link to display text and a hyperlink link.setText("This is a simple <A>link</A>.");