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.