Using Java Swing to implement the QQ Login interface sample sharing _java

Source: Internet
Author: User

A QQ login interface made with Java Swing

Copy Code code as follows:

Import Java.awt.Container;
Import Java.awt.Image;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;

Import Javax.swing.ImageIcon;
Import Javax.swing.JButton;
Import Javax.swing.JCheckBox;
Import Javax.swing.JComboBox;
Import Javax.swing.JFrame;
Import Javax.swing.JLabel;
Import Javax.swing.JOptionPane;
Import Javax.swing.JPasswordField;
Import Javax.swing.JTextField;

/**
* Imitation QQ Login Interface
*
* @author Jiang
*/
public class Guiqq extends JFrame {
User name
Private JTextField username;
Password
private JPasswordField password;
Small container
Private JLabel jl1;
Private JLabel Jl2;
Private JLabel Jl3;
Private JLabel Jl4;

Small button
Private JButton bu1;
Private JButton bu2;
Private JButton Bu3;

check box
Private Jcheckbox jc1;
Private Jcheckbox JC2;

list box
Private JComboBox JCB;

/*
* Construction Method
*/
Public Guiqq () {
Set window title
This.settitle ("QQ2012 official edition");
Form component Initialization
Init ();
This.setdefaultcloseoperation (Jframe.exit_on_close);
Set layout mode to absolute positioning
This.setlayout (NULL);

This.setbounds (0, 0, 355, 265);
Set the title icon for a form
Image image = new ImageIcon ("E:/a.gif"). GetImage ();
This.seticonimage (image);

Form size cannot be changed
This.setresizable (FALSE);

Center Display
This.setlocationrelativeto (NULL);

Form visible
This.setvisible (TRUE);
}

/*
* Initialization method
*/
public void init () {
Create a container
Container con = This.getcontentpane ();
JL1 = new JLabel ();
Set background picture
Image image1 = new ImageIcon ("E:/background.jpg"). GetImage ();
Jl1.seticon (New ImageIcon (Image1));
Jl1.setbounds (0, 0, 355, 265);

QQ Login Avatar Set
JL2 = new JLabel ();
Image image2 = new ImageIcon ("E:/a.gif"). GetImage ();
Jl2.seticon (New ImageIcon (Image2));
Jl2.setbounds (40, 95, 50, 60);

User Number Login Input box
Username = new JTextField ();
Username.setbounds (100, 100, 150, 20);
User number login text next to the input box
Jl3 = new JLabel ("registered account");
Jl3.setbounds (260, 100, 70, 20);

Password input Box
Password = new JPasswordField ();
Password.setbounds (100, 130, 150, 20);
Text next to the Password entry box
Jl4 = new JLabel ("Retrieve password");
Jl4.setbounds (260, 130, 70, 20);

Text below input box
JC1 = new Jcheckbox ("Remember Password");
Jc1.setbounds (105, 155, 80, 15);
JC2 = new Jcheckbox ("Auto login");
Jc2.setbounds (185, 155, 80, 15);
User Logon Status Selection
JCB = new JComboBox ();
Jcb.additem ("online");
Jcb.additem ("stealth");
Jcb.additem ("Leave");
Jcb.setbounds (40, 150, 55, 20);

Button setting
BU1 = new JButton ("login");
Bu1.setbounds (280, 200, 65, 20);
Add 1 events to a button
Bu1.addactionlistener (new ActionListener () {

@Override
public void actionperformed (ActionEvent e) {
String Str=e.getactioncommand ();
if ("Login". Equals (str)) {
String getName =username.gettext ();
String getpwd =password.gettext ();
Joptionpane.showconfirmdialog (NULL, "The username you entered is" +getname);
}

}
});
BU2 = new JButton ("multiple account");
Bu2.setbounds (5, 200, 75, 20);
BU3 = new JButton ("Settings");
Bu3.setbounds (100, 200, 65, 20);

All components loaded in containers
Jl1.add (JL2);
Jl1.add (JL3);
Jl1.add (JL4);
Jl1.add (JC1);
Jl1.add (JC2);
Jl1.add (JCB);
Jl1.add (BU1);
Jl1.add (BU2);
Jl1.add (BU3);
Con.add (JL1);
Con.add (username);
Con.add (password);
}
public static void Main (string[] args) {
Instantiating an Object
GUIQQ QQ = new GUIQQ ();
}

}

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.