Hyperlink is a custom widget created to complement the standard SWT widget set when used in the context of UI Forms. Hyperlink is a selectable text control that acts like a Web browser hyperlink:
Hyperlink link = toolkit.createHyperlink(form.getBody(), "Click here.", SWT.WRAP); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { System.out.println("Link activated!"); } }); link.setText("A sample link");
Hyperlinks fire HyperlinkEvent
objects when users interact with
them. By adding a HyperlinkListener
, clients can capture when the
mouse enters and exits the link, as well as activates it (either by mouse click
or by 'Enter' key).
Hyperlinks created by the form toolkit are automatically inserted into a
hyperlink group. HyperlinkGroup
manages common hyperlink
properties like normal and hover foreground color, underline style etc. for all
the links that belong to the group.
Since many hyperlinks are combined with a small image, UI Forms provide a
subclass called ImageHyperlink
that add the ability to combine text
and image in one clickable control. This class can also be used when a hyperlink
image (without text) is needed. If image is not set, ImageHyperlink
behaves identically to Hyperlink
.