четверг, 28 июля 2011 г.

WindowBuilder Pro, Hello World Java Swing

WindowBuilder Pro, Hello World Java Swing

>> 25 January 2011

A step by step tutor with images, Hello World Java Swing application, using WindowBuilder. This tutor describe the installation and Hello World Swing application.

WindowBuilder is a powerful and easy to use bi-directional Java GUI designer. It is composed of SWT Designer, Swing Designer and GWT Designer.

WindowBuilder Pro is built as a plug-in to Eclipse.

Very easy to use with it's WYSIWYG layout, with a drag and drop capabilities.

After Google have acquired Instantiations, WindowBuilder becomes new open source project with major code contribution to Eclipse Foundation.



Thanks Google :)









Installation :


In Eclipse -> Help menu -> Install New Software



In the text field "Work with" enter the plug-in location of your Eclipse version ( Eclipse 3.6 Helios :
http://dl.google.com/eclipse/inst/d2wbpro/latest/3.6)

Click on "Add" button




Give a name of your choice to this Repository -> Click on "OK"




In "Available Software" dialog -> Select All -> Next




Install Details -> Next





Review the license -> I accept -> Finish




Installing Software





In "Security Warning" -> Click "OK" to continue




When installation finished -> Restart Now




Hello World Swing

Create a new Java Project

File menu -> New -> Java Project




Give a name to your project in "Project name" -> Finish








In "Package Explorer" -> Right click the project name -> New -> Other




In "Select a wizard" dialog -> Select WindowBuilder -> Swing Designer -> Jframe -> Next




Enter a name for the JFrame -> Finish




HelloWorldFrame.java (the name given to the JFrame class) is opened in the editor (source). To open the Swing Designer -> Click on "Design" tab








To open the Swing palette in it's own view -> Window menu -> Show View -> Other




Under WindowBuilder -> Palette








Add JLabel to the Frame
Click on JLabel component in the palette -> Drag to the Frame








Drop on the Frame. The JLabel is added




In the "Properties" dialog -> Modify the label's text -> Hello World Swing !!!




The source is modified. Notice the clean code.




Run the application

Right click on the project (in Package Explorer) -> Run As -> Java Application





Et voilà



Going further

Other modification to JFrame are easy made, like changing the Frame's title, icon, or adding any other components, or modifying the layout, etc.
Enjoy an easy and efficient design.



References :
http://code.google.com/javadevtools/wbpro/
http://code.google.com/javadevtools/download-wbpro.html

Комментариев нет:

Отправить комментарий