In Eclipse, File | Import...| Existing Projects Into Workspace | Next | Select root directory | Browse to the template project's root directory | OK. Finish.
Author's Note: A description of the most significant files and folders in the project template can be found at the end of this article.
Usage To Start a New Project Based on the SWT Project Template:
Right-click on the template project | Copy.
Right-click in an empty area of the Package Explorer | Paste.
Check the default location checkbox.
Change the Project name to the name of your new project. Click OK. A copy of the template project will be created in the Package Explorer.
In your new project, expand the src directory. Now, right-click on the package named change_this_pkg_name. Select Refactor | Rename... and change the package name to something appropriate for you project. For example, if your project name is MyApplication, make the package name com.mycompany.myapplication. Then click Preview | Continue | OK.
To run your application, go to the Package Explorer and expand your (renamed) package, then right-click on MainWindow and select Run As | Java Application (note that it's not run as SWT application).
To Add UI Controls to the Window:
If you are using Jigloo to edit the GUI, right-click on MainWindow in the Package Explorer, then select Open With | Form Editor. If you are using a different GUI builder, follow its standard procedure for opening a visual class.
Drag a UI control into the clientArea composite. This composite defaults to the Absolute (null) layout.
To Set the Status Bar Text:
In any method of the MainWindow class, call setStatus(String).
To Change the Cursor:
In any method of the MainWindow class, call setCursor(waitCursor) to display the system waiting cursor (typically an hour glass), or setCursor(defaultCursor) to display the default cursor (typically an arrow).
To Read or Write Text Files:
To read the contents of a text file into a String, use
String someString = TextFile.read("blah.txt");
To write the contents of a String to a file, use
To Get Help for an SWT Class or Method:
Hover the cursor over the class or method name.
Put the cursor in a class or method name, then type Shift-F2. Your browser will be directed to Eclipse's online help.
To Access the Application Preferences:
The application preferences are stored in a Properties object called appSettings. The settings are loaded from appsettings.ini on startup. They are saved back to appsettings.ini when the user selects exit from the file menu.
To set a preference, use appSettings.setProperty("myProperty", "my value");
To get a preference, use appSettings.getProperty("myProperty", "default value");