Java-JFrame visual development and java-jframe Visualization

Source: Internet
Author: User

Java-JFrame visual development and java-jframe Visualization

General steps for Java-JFrame Visual Development

JFrame can be used to create a form similar to the QQ login function. JFrame can use Java code to implement the form function, which is generally used for C (client) Development of the CS project;

You can use JFrame to write java code by yourself, or install the windowbuilder plug-in eclipse. In this way, you can use the windowbuilder plug-in to visually and quickly create and operate the form, and quickly implement programming development;

The general steps for visual development of JFrame forms using the windowbuilder plug-in eclipse are as follows:

1. Add the windowbuilder plug-in to eclipse:

1. First, check your eclipse version:

2, through the eclipse version of windowbuilder plug-in online selection of the corresponding version of the http address: URL: http://www.eclipse.org/windowbuilder/download.php

3. then install the windowbuilder plug-in eclipse:

Eclipse --> help --> Install New Software:

Name: enter a Name. It is best to know the Name, for example, windowbuilder.

Looin: Write the address in the http column obtained based on the eclipse version;

Next, select all, and then click Next. After that, restart eclipse to complete the process;

2. Create a windowbuilder java project in eclipse and a java entity class for visual development:

1. Create a java project using windowbuilder:

2. Create a java object class through windowbuilder: new ---> other:

After creating a java object class, you can use windowbuilder to visually open the java object class:

 

3. Develop a JFrame form by using visualized java entity classes and compiling java code in Entity classes: add different function blocks to the form, beautify the form, and add various events to develop the JFrame form. For detailed operations, see the following general functions;

4. Use the windowbuilder plug-in eclipse to develop the common functions used by the form JFrame:

Note: Any JFrame must first perform this step:

You can set the centralized data for all functional blocks in the form: function block name, xy positioning, width, height, font style, and alignment;

(1) Add different functional blocks to the form:

1. Text Content:

2. Common input box (can be entered ):

3. Common input box (read-only ):

4. Password Input box:

5. Single-choice button: (it is best to put it in a JPanel for easy selection)

Add the following buttons:

Using java code, you can manually add multiple buttons to a ButtonGroup to implement the single-choice function:

6. Select multiple buttons: (it is best to put them in a JPanel for easy selection)

7. drop-down menu:

8. submit button:

9. Date control:

10. Form jump:

 

Then, you can directly write the method body in the Override method, that is, you can create a new object through new.

11. Jump form transfer parameters:

Similar to the jump form, it is only in the Override method that, first obtain the parameter value to be passed, and then let the parameter value pass the parameter to another form through the construction method with parameters;

12. Insert a background image:

To insert an image, layers of JLayeredPane are usually used, and then JPanel is created. Then, JLabel is created in JPanel to add the ImageIcon object of the image to JLabel. If you need to set the image size, you need to set both the ImageIcon object and the JPanel;

(2) obtain the values of different functional blocks:

1. Get the content entered in the input box:

Obtain this element. Call the getText () method to obtain the string value.

2. select a single-choice button:

Determine each JRadioButton in the JPanel, and obtain the element if it is selected, and then call getText () to obtain the value;

3. Select multiple buttons:

First, obtain the number of multiple buttons Under the JPanel, and traverse each button to determine whether the button is selected. if selected, obtain the element and call the getText () method to obtain the value, store it in an array;

4. Obtain the selected value from the drop-down menu:

Obtain this element, call the getSelectedItem () method, and call toString () to convert it to a string;

5. Obtain the date control selection value:

Obtain this element and convert it to a DatePicker type element. Call the getText () method;

(3) add different events to function blocks in the form:

1. Mouse Click Event:

Add event:

Compile the method body: Write the corresponding java code in the method body;

Move the cursor to the event, remove the event, press the event, and pop up the event;

2. Obtain the cursor event:

Add event:

Compile the method body: Write the corresponding Java code in the method body;

The event of losing the cursor is similar;

3. add other events (you need to search again later): Many events are used in add event handler. Learn more;

(4) other common functions:

1. Insert multiple background images for hierarchical display:

It is very similar to inserting a common background image. The difference is that when the JPanel object is added to the JLayeredPane object, the setting is added to the bottom layer;

2. Set the transparency of the content on the background image to display the background image:

First, it is the same as inserting multiple background images for hierarchical display. After adding a background image, you can create a JPanel object and add the object to a higher layer of JLayeredPane. Set the JPanel object to transparent, the background image is displayed;

3. input box rounded corner: (you have your own tool class. For details, see java code in the util tool class of the project in the core code)

Create an object with the corresponding boundary Linearity:

Set the boundary style to the linear object of the created boundary as needed:

4. Only the following lines are displayed in the input box;

5. form rounded corners:

6. Button Custom Button (background color + rounded corner + Click effect ):

Use the Custom button. For specific code, see the code in the Login1 entity class of the project in the core code.

7, verification code function: In the blog has a detailed introduction, blog Verification Code Web site: http://www.cnblogs.com/lsy-blogs/p/7665974.html

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.