In this section, you will study how to create Link in a text.
SWT allows to create link by using the class Link of package org.eclipse.swt.widgets. The class Link displays the specified text with links. The method setText(message) sets the text specified.
Following code calls the Event class and print the selected link on the console:
| ink.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { System.out.println("You have selected: "+event.text); } }); |
Here is the code of CreateLinkExample.java
import org.eclipse.swt.SWT; |
Output will be displayed as:

On selecting Platform Independent, it will be printed on the console.
![]()
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: How to create Link in SWT
Post your Comment