Designing Swing programs with Windowbuilder

Source: Internet
Author: User
Tags blank page

The swing program represents a Java client-side form program, in addition to designing the Swing program by writing code manually, Eclipse also provides a windowbuilder tool, a very useful swing visual development tool, with it, Developers can write swing programs in the same way as Visual Studio by dragging and dropping components, and the following is a detailed introduction to designing swing programs using the Windowbuilder development tool.

A.1 Download Windowbuilder Tools
There are two ways to download the Windowbuilder tool, one is to download the eclipse of the integrated Windowbuilder tool directly, and the other is to install it by installing NEW software, as described below.
? Download the eclipse for the integrated Windowbuilder tool
The Eclipse download page on the Eclipse's official website offers a variety of eclipse tools, including an Eclipse IDE for Java developers option, which integrates the Windowbuilder tool Users only need to download the appropriate version based on their operating system number, as shown in A.1.

Figure A.1 Download the eclipse of the integrated Windowbuilder tool

? Installing the Windowbuilder tool with the install New software
If a user downloads an eclipse version that is not "eclipse IDE for Java developers", you will need to install it manually if you want to use the Windowbuilder tool to develop the swing program, as follows:
(1) Open Eclipse and select the "Help/about Eclipse" menu in the Eclipse menu, as shown in A.2.

Figure A.2 Select the Help/about Eclipse menu

(2) The "About Eclipse" dialog box appears, which shows the version of Eclipse, as shown in A.3.

Figure A.3 Viewing the version of Eclipse
(3) Enter the URL http://www.eclipse.org/windowbuilder/download.php in the address bar of the IE browser and enter the Windowbuilder download interface of the Eclipse website, as shown in A.4.

Figure A.4 Windowbuilder Download interface

(4) Click on the link in "Update Site" under "Release version" for your version of Eclipse, select the "4.5 (Mars)" version, go to a blank page, copy the URL of the blank page (HTTP/ DOWNLOAD.ECLIPSE.ORG/WINDOWBUILDER/WB/RELEASE/R201506241200-1/4.5/)

(5) Open Eclipse and select the "Help/install New Software" menu in the Eclipse menu, as shown in A.5.

Figure A.5 Select the Help/install New software menu

(6) Pop Up the Install dialog box, as shown in A.6.

Figure A.6 Install dialog box

(7) Click the Add button in the Install dialog box to bring up the "Add Repository" dialog box, A.7, in the dialog box, in the Name text box, enter the name of the plug-in that you want to install in the Windowbuilder;location text box to enter the update address for the Windowbuilder tool (that is, the copy of http://In step (4) DOWNLOAD.ECLIPSE.ORG/WINDOWBUILDER/WB/RELEASE/R201506241200-1/4.5/)

Figure A.7 "Add Repository" dialog box

(8) Click the OK button to return to the Install dialog box, select the update content of the Windowbuilder tool, and then follow the prompts to install the Windowbuilder tool into eclipse, as shown in A.8.

Figure A.8 Installing the Windowbuilder tool

A.2 Designing forms with Windowbuilder
After you have installed the Windowbuilder tool for Eclipse, you can use Windowbuilder to design the swing program, with the following steps:

(1) Create a new Java project, right-click on the Java project and choose the "new/other" shortcut menu, as shown in a.9.

Figure A.9 Select the New/other shortcut menu

(2) The New dialog box pops up, so the windowbuilder/swing Designer menu is expanded, and the JFrame menu item is selected, as shown in a.10.

Figure a.10 jframe menu item selected

(3) Click the Next button to go to the "New JFrame" dialog box, enter the corresponding package name (pack) and form name (name), as shown in a.11.

Figure a.11 "New JFrame" dialog box

Note: When you create a JFrame form, you must rely on a Java project, where the Source folder text box in the New JFrame dialog box cannot be empty, or the error message shown in A.12 will appear.

(4) Click the Finish button to create a JFrame form. After you create the JFrame form in the Java file, the system automatically generates some code, as shown in a.13.

Figure a.13 Auto-generated jframe form code

(5) Click the Design tab at the bottom to switch to the visual design interface, shown in A.14, which has 3 main areas, the Component Toolbox, the form design area, and attributes, where the component Toolbox provides the layout managers, containers, and various components needed to design the swing program The form design area is mainly used for visual design of the form, and the property area is used to set the related properties of the form or component, thus eliminating the process of writing code to set properties, which is more convenient and quick.

Figure a.14 jframe Visual Design interface
(6) in the visual design interface, the user can draw the corresponding components in the form according to their actual needs, and set the properties of the components, the specific action of drawing the component is: on the left side of the component Toolbox, select the component that you want to display on the form, and then move the mouse to the form design area. A mouse shape with a green origin is displayed, and a corresponding component is drawn in an area by clicking the left mouse button, as shown in a.15.

Figure a.15 Drawing components in the JFrame form

Description: After you have created the JFrame form, the default layout is BorderLayout border layout, and if you want to cancel the layout, you can press the DELETE key directly in the form design area. Then switch to the. java file (click the Source tab at the bottom) to set the parameter of the SetLayout method to null.

Designing Swing programs with Windowbuilder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.