Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Standard Widget Toolkit
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Programming === [[File:Screenshot-swt-helloworld.png|thumb|A simple GUI application using SWT running in a [[GTK]] environment]] The following is a basic [["Hello, World!" program]] using SWT. It shows a window (''Shell'') and a label. <syntaxhighlight lang="java"> import org.eclipse.swt.*; import org.eclipse.swt.widgets.*; public class HelloWorld { 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.pack(); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } </syntaxhighlight> Contrary to [[Swing (Java)|Swing]], a ''Display'' class is necessary to access the underlying [[operating system]], and its resources must be explicitly disposed of when they are no longer used.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)