import org.eclipse.swt.widgets.*; public class LabelExample { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.NONE); label.setText("Hello, World!"); label.setEnabled(false); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }
import org.eclipse.swt.widgets.*; public class LabelExample { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Label label = new Label(shell, SWT.NONE); label.setText("Hello, World!"); label.setEnabled(true); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } }In this example, we create a new Label and set its text to "Hello, World!". We then enable the label using the setEnabled() method, which allows the user to interact with the label. Overall, the setEnabled() method of the Label class is a useful tool for controlling the user's ability to interact with a label component in Java SWT applications.