Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Build Faster with This Turnkey SWT Project Template-2 : Page 2


advertisement
Installation
  1. Download and extract the SWT Project Template.
  2. 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:

  1. Right-click on the template project | Copy.
  2. Right-click in an empty area of the Package Explorer | Paste.
  3. Check the default location checkbox.
  4. 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.
  5. 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.
  6. 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:
  1. 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.
  2. Drag a UI control into the clientArea composite. This composite defaults to the Absolute (null) layout.
To Set the Status Bar Text:
  1. In any method of the MainWindow class, call setStatus(String).
To Change the Cursor:
  1. 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:
  1. To read the contents of a text file into a String, use

    String someString = TextFile.read("blah.txt");

  2. To write the contents of a String to a file, use


    TextFile.write("blah.txt", someString);

To Get Help for an SWT Class or Method:
  1. Hover the cursor over the class or method name.
    or
  2. 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.
  1. To set a preference, use appSettings.setProperty("myProperty", "my value");
  2. To get a preference, use appSettings.getProperty("myProperty", "default value");



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap