Java Desktop Application Development Study Note 1

Source: Internet
Author: User

 

 

 

Learning Java Desktop Application Development _ login form

Recently, the company used Java to build a C/S project and ran a plug-in (windowbuilder. Pro. v6.1.1) on Eclipse. As I was just beginning to study Java swing, I wanted to record some of my development efforts with caution, hoping to help people who need help. At the same time, it also helped me to deepen my impression ..

First, let's look:

This form is running in the middle of the screen and is of a fixed size ..

Slow! Maybe you will say what is difficult. In. net, it is very simple (very simple), but you need to know that it is not very easy to get started with j2se ..

In fact, you need to pay attention to the following three points:
1. Use the jpanel layout (jpanel in swing). Pay attention to the layout method (borderlayout, flowlayout, gridlayout .....), here I am using null and there is no layout. In this way, we can control the position of the control as we like .. Drag the control from the toolbox to the corresponding position ..

2. demo of setting the form center

This. setlocationrelativeto (null );

3. Set the fixed size of the form.

This. setresizable (false );

 

Implement carriage return Login

Check the Code:

Code

 1 Public void show ()
2 {
3 // enter the password and press enter, which is equivalent to clicking the logon Password box.
4 getrootpane (). setdefaultbutton (btnlogin); // specify the "enter" button
5 // positioning focus
6 txtuserpwd. requestfocus ();
7
8 setdefaclocloseoperation (dispose_on_close );
9 super. Show ();
10}

 

If you need plug-ins and examples, you can leave an email to send them to you ..

I wrote blog for the first time. If you have any shortcomings, please forgive me and correct me.

 

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.