SWT (Standard Widget Toolkit) is the "Java" graphical interface development library launched by IBM. I said that it is "Java" means that when programmers write code, use Java language, in fact the bottom level of SWT It is completed in C language. But these are transparent to programmers.
When we use the SWT to develop the GUI program, we will write directly with the SWT API. In fact, many Java code is implemented by JNI to remove C code. There are different implementations for each class for different platforms. The purpose of this article is not to describe the design principle of SWT. If you are interested in these, you can refer to http://www.eclipse.org/articles/article-swt -Design-1 / swt-design-1.html.
Here, you will start to use SWT, first of all, I assume that you have installed Eclipse3.0, of course, other versions can be downloaded, if you haven't yet, you can download it from www.eclipse.org.
Run Eclipse, switch to the Java perspective, new Java Project from Package Explore. Name Test In Libraries Select Add External Jars to add the class library required to run SWT, this and the system are related, for example, under Windows XP, the address is: D: /Eclipse/plugins/org.eclipse.swt.win32_3 .0.0 / ws / win32 / swt.jar. Add it to it, it is recommended to make a variables point to this swt.jar file, and add Variables directly to write Java code, such as import org.eclipse.swt.widgets. *; Import org.eclipse.swt. *; Public class SWTHELLO {public static void main (string [] args) {display display = new display (); shell shell = new shell (label label = new label (shell, swt.none); label.settext ("Hello, World! "); Shell.Pack (); label.pack (); shell.Open (); while (! Shell.iedisposed ()) if (! Display.readanddispatch ()) display.sleep (); display.dispose (); label.dispose ();}} Configure the running environment. Because the SWT program is used to use this unit, if you now run the above program, there will be an error, similar to java.lang.unsatisfiedlinkerror: no SWT-win32-2133 in java.library.path, so you must specify the location you need, the specific practice is: Switch from the menu Run-> Run to the Run Configuration interface, select Arguments to write in VM Arguments - DJAVA .library.path =