Skip to content

Instantly share code, notes, and snippets.

@deepking
Created February 13, 2014 07:46
Show Gist options
  • Save deepking/8971350 to your computer and use it in GitHub Desktop.
Save deepking/8971350 to your computer and use it in GitHub Desktop.
SWT HelloWorld sample
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
public class HelloSWT
{
public static void main(String[] args)
{
// Allocation and initialization
Display display = new Display();
Shell shell = new Shell(display);
// Adding widgets to the shell
Text helloText = new Text(shell, SWT.CENTER);
helloText.setText("Hello SWT!");
helloText.pack();
// GUI operation
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment