Java Network Programming--Login Interface Buddy interface

Source: Internet
Author: User
Tags password protection

Introduction

??

This is part of the Java interface Programming, not the focus of network programming, but also a little bit about these two interfaces

??

Login interface

??

The login interface you want to end up with

??

??

Analysis interface

??

This interface can be divided into three large parts, a picture of the north,qq2003 new experience Q Human, central QQ number, mobile phone number and Email login section, as well as the following three buttons, the middle of the QQ number label, number input box, clear Number button,QQ password label, password input box, forget password label, and Stealth login, remember password Checkbox, plus the Apply password protection button, these nine can be done with a 3x3 Network layout

??

and QQ number, mobile phone number and Email login These three can switch the Label can be used JTabbedPane

??

Interface programming

??

First the picture of the North component can be a JLabel, then pass the picture as a parameter

??

JLabel = new JLabel (New ImageIcon ("Image/tou.gif"));

??

and add it to the north of JFrame .

??

This.add (JLabel, "North");

??

Then the southern component of the three buttons can be put three JButton in a JPanel

??

JPanel = new JPanel ();

JPanelButton1 = new JButton (New ImageIcon ("Image/denglu.gif"));

Jpanelbutton1.addactionlistener (this);

JPanelButton2 = new JButton (New ImageIcon ("Image/quxiao.gif"));

JPanelButton3 = new JButton (New ImageIcon ("Image/xiangdao.gif"));

Jpanel.add (JPanelButton1);

Jpanel.add (JPanelButton2);

Jpanel.add (JPanelButton3);

This.add (JPanel, "South");

??

Central components are more complex, mainly to achieve the ability to switch tabs

??

First of all, we're going to make 3x3 grid things.

??

JPanel1 = new JPanel (New GridLayout (3, 3));

Jpanel1_jlabel1 = new JLabel ("QQ number", jlabel.center);

Jpanel1_jlabel2 = new JLabel ("QQ password", jlabel.center);

Jpanel1_jlabel3 = new JLabel ("Forgot password");

Jpanel1_jlabel4 = new JLabel ("Application password protection");

Jpanel1_jbutton = new JButton (New ImageIcon ("Image/clear.gif"));

Jpanel1_usernamefield = new JTextField ();

Jpanel1_passwordfield = new JPasswordField ();

Jpanel1_checkbox1 = new Jcheckbox ("Stealth login");

Jpanel1_checkbox2 = new Jcheckbox ("Remember Password");

Jpanel1.add (JPANEL1_JLABEL1);

Jpanel1.add (Jpanel1_usernamefield);

Jpanel1.add (Jpanel1_jbutton);

Jpanel1.add (JPANEL1_JLABEL2);

Jpanel1.add (Jpanel1_passwordfield);

Jpanel1.add (JPANEL1_JLABEL3);

Jpanel1.add (Jpanel1_checkbox1);

Jpanel1.add (JPANEL1_CHECKBOX2);

Jpanel1.add (JPANEL1_JLABEL4);

??

Then we except the QQ number of this tab has been done (JPANEL1), we put the back two tabs ( mobile phone number and Email corresponding tab also done )

??

JPanel2 = new JPanel ();

JPanel3 = new JPanel ();

??

Finally, we create a JTabbedPane to put these three JPanel in.

??

JTabbedPane = new JTabbedPane ();

Jtabbedpane.add ("QQ number", JPanel1);

Jtabbedpane.add ("Mobile phone number", JPANEL2);

Jtabbedpane.add ("Email", jPanel3);

This.add (JTabbedPane, "Center");

??

At this point the login interface is ready, Next is the QQ friend interface

??

QQ Friend interface

??

We want to make the QQ friend interface into the following form

??

??

Analysis interface

??

This interface can be divided into three parts, the top of my friend, can be a Button, linked to the middle of the Friend list, friends list to achieve the function of pull down, you can use a JScrollPane implementation, the bottom is two Button, can be placed in a 2x1 Grid layout

??

To put my friend on this interface, the layout is borderlayout.

Friendpanel1=new JPanel (New BorderLayout ());

Used to show Friends list

Friendpanel2=new JPanel (New GridLayout (50, 1, 4, 4));

Used to put Strangers, blacklist buttons

Friendpanel3=new JPanel (New GridLayout (2,1));

??

Put my friends button in FriendPanel1

Friendpanel_button1=new JButton ("My Friends");

Friendpanel1.add (Friendpanel_button1, "North");

??

Put your friends list in FriendPanel1

Initialize your friends list, use a JLabel array to put your friends list, each friend is a JLabel

Jlabel[] friendslist;

Friendslist=new JLABEL[50];

for (int i = 0; i < friendslist.length; i++) {

Friendslist[i]=new JLabel (i+1+ "", New ImageIcon ("Image/mm.jpg"), Jlabel.left);

Put each jlabel into the FriendPanel2

Friendpanel2.add (Friendslist[i]);

}

Put the FriendPanel2 into JScrollPane

Friendpanel_jscrollpane=new JScrollPane (FRIENDPANEL2);

Put your buddy list, JScrollPane, into FriendPanel1

Friendpanel1.add (Friendpanel_jscrollpane, "Center");

??

Put two buttons in the south into FriendPanel1

Friendpanel_button2=new JButton ("Stranger");

Friendpanel_button3=new JButton ("blacklist");

Friendpanel3.add (Friendpanel_button2);

Friendpanel3.add (Friendpanel_button3);

Friendpanel1.add (FriendPanel3, "South");

??

Stranger interface

??

Another thing we want to do is to switch to the Stranger interface when you click the Strangers button.

??

??

One simple way to do this is to define as many components as we do with the Buddy interface.

??

// used to put a stranger on this interface, layout for borderlayout .

??

Msrpanel1=new JPanel (New BorderLayout ());

??

??

First the north now becomes the Panel of the grid portion of the two buttons

??

Msrpanel3=new JPanel (New GridLayout (2,1));

??

Put this panel into MsrPanel1

Msrpanel_button1=new JButton ("My Friends");

Msrpanel_button2=new JButton ("Stranger");

Msrpanel3.add (Msrpanel_button1);

Msrpanel3.add (Msrpanel_button2);

Msrpanel1.add (MsrPanel3, "North");

??

The middle is still a jscrollpane used to show strangers list

??

Msrpanel2=new JPanel (New GridLayout (20, 1, 4, 4));

Jlabel[] Msrlist=new jlabel[20];

for (int i = 0; i < msrlist.length; i++) {

Msrlist[i]=new JLabel (i+1+ "", New ImageIcon ("Image/mm.jpg"), Jlabel.left);

Msrpanel2.add (Msrlist[i]);

}

Msrpanel_jscrollpane=new JScrollPane (MSRPANEL2);

Msrpanel1.add (Msrpanel_jscrollpane, "Center");

??

And finally, a Southern blacklist button.

??

Msrpanel_button3=new JButton ("blacklist");

Msrpanel1.add (Msrpanel_button3, "South");

??

So far we've had a problem with how to switch back and forth between these two interfaces.

??

Here we are going to set the layout of the JFrame itself to cardlayout

??

Cl=new cardlayout ();

This.setlayout (CL);

??

And then add my friends, strangers, to this card layout.

??

This.add (FriendPanel1, "1");

This.add (MsrPanel1, "2");

??

And then we're going to listen to the Stranger in my Buddy interface, and when we do, we switch to the stranger interface.

Also listen to my friend's button in the Stranger interface, and when pressed we switch to my friends screen

??

if (E.getsource () ==friendpanel_button2) {

Cl.show (This.getcontentpane (), "2");

}

if (E.getsource () ==msrpanel_button1) {

Cl.show (This.getcontentpane (), "1");

}

??

Achieve the mouse on the friend above the different color display

??

Also use the mouse to listen for events,entered event Exited Events

??

public void mouseentered (MouseEvent e) {

TODO auto-generated Method Stub

JLabel jlabel= (JLabel) E.getsource ();

Jlabel.setforeground (color.red);

}

public void mouseexited (MouseEvent e) {

TODO auto-generated Method Stub

JLabel jlabel= (JLabel) E.getsource ();

Jlabel.setforeground (Color.Black);

}

Java Network Programming--Login Interface Buddy interface

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.