Saturday, 3 September 2011

Designing Swing / SWT GUIs using WindowsBuilder in Eclipse Indigo

The latest release of Eclipse code named Indigo includes the WindowsBuilder project as an open source project within the Eclipse umbrella of projects. WindowsBuilder which is a significant GUI designing tool in its own right provides a WYSIWYG editor for desgining Swing and SWT interfaces from within Eclipse.

WindowsBuilder comes bundled with the standard download 'Eclipse IDE for Java Developers' but if you choose to download another version of Eclipse and you need to manually add the plugin, , goto Help->Install New Software -> and in the 'worh with' box enter the site : site http://dl.google.com/eclipse/inst/d2wbpro/latest/3.7  and then follow the usual steps for adding the plugin. After successfully installing it, you will be able to view the plug-in in the 'Installation History' and the'Plugins' tab of Eclipse Installation Details.


Now that you have WindowsBuilder installed, creating Swing / SWT based GUIs is just a matter of clicking through a few wizards. To create a screen using the wizard, create a Java project and then select New-> Other->WindowsBuilder and open up the wizard.

Other->WindowsBuilder and open up the wizard. Select the required option. In this case, I selected 'ApplicationWindow' and the wizard generates the ApplicationWindow for me as shown in the screenshot.
At the bottom of the editor view, there will be two options, 'Source' and 'Design'. Click on the Design option. This will open the design page and load up the pallet and give you the WYSIWYG option.You can now see your 'frame' object on the right hand side and the pallet with different Swing and SWT controls that you can use. I added a JPanel and set its layout to 'JGoodiesFormLayout' and then added a couple of labels, textboxes and a 'Send' button.
Add the required controls you need. You can also select any of the controls and add any EventHandlers that you might need by right clicking on the controls.


The wizard will create skeleton code for you which you can customize as required. Once you are done, just run the application.




Finally, if you want a different 'Look and Feel', especially a 'Native Platform' look, the WindowsBuilder has an option in the top menu, that allows you to change the Look and Feel as shown in the screenshot below.


Thus, within a few minutes, you can design a fully functional Java application with a few bells and whistles. This is very useful, if you need a prototype and some sample screenshots to show the user. Instead of wasting time,drawing the screens in a prototyping tool, create the same using the WindowsBuilder plugin and when the client gives you the green light, come back to your prototype, clean up the code and add the required functionality. Finally, there are a couple of good tutorials on YouTube that describe using WindowsBuilder with Eclipse.

1 comment:

Superbowl2012 said...

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
SEO tools