Development environment: Eclipse neon.3 Release (4.6.3)
I used the Java EE version, in order to facilitate the design interface, the need to install Windowbuilder plug-ins, can be directly in the marketplace search.
Description: Refer to Kego video synchronization learning
Interface Effect
Login interface
Registration interface
Key Technologies
This project uses the Java Swing appearance plug-in
Use the picture (click the src Right folder named res and copy the picture login.jpg) source code
Com.lsh.view.LoginDialog
Package Com.lsh.view;
Import Java.awt.BorderLayout;
Import Javax.swing.JButton;
Import Javax.swing.JDialog;
Import Javax.swing.JPanel;
Import Javax.swing.border.EmptyBorder;
Import Javax.swing.JTextField;
Import Javax.swing.JLabel;
Import Java.awt.event.ActionListener;
Import java.awt.event.ActionEvent;
Import Javax.swing.ImageIcon;
Import Javax.swing.border.TitledBorder;
Import Com.lsh.util.ImageScale; @SuppressWarnings ("Serial") public class Logindialog extends JDialog {private final JPanel Contentpanel = new JPanel
();
Private JTextField TextField;
Private JTextField textfield_1;
Private JTextField textfield_2;
Private JTextField textfield_3;
Private JTextField Textfield_4;
Private JTextField textfield_5;
private static final int dialog_width=414;
private static final int dialog_height=340;
private static final int dialog_height_extend=573;
/** * Launch the application.
*/public static void main (string[] args) { try {Org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF (); The catch (Exception e) {//todo Exception System.out.println ("Load dazzle skin failed.")
");
try {logindialog dialog = new Logindialog ();
Dialog.setdefaultcloseoperation (Jdialog.dispose_on_close);
Dialog.setvisible (TRUE);
catch (Exception e) {e.printstacktrace ();
}/** * Create the dialog.
*/Public Logindialog () {setalwaysontop (true);
Setresizable (FALSE);
SetBounds (n, dialog_width,dialog_height);
Getcontentpane (). setlayout (New BorderLayout ());
Contentpanel.setborder (New Emptyborder (5, 5, 5, 5));
Getcontentpane (). Add (Contentpanel, borderlayout.center);
Contentpanel.setlayout (NULL);
Sets the center//setlocation (Windowxy.getxy (LoginDialog.this.getSize ())); JButton Btnnewbutton= new JButton ("register");
Btnnewbutton.addactionlistener (new ActionListener () {public void actionperformed (ActionEvent arg0) { if (LoginDialog.this.getHeight () ==dialog_height_extend) {LoginDialog.this.setSize (Dialog_width,
Dialog_height);
} else{LoginDialog.this.setSize (dialog_width,dialog_height_extend);
}
}
});
Btnnewbutton.setbounds (53, 224, 93, 23);
Contentpanel.add (Btnnewbutton);
JButton btnnewbutton_1 = new JButton ("login");
Btnnewbutton_1.setbounds (190, 224, 93, 23);
Contentpanel.add (btnnewbutton_1);
TextField = new JTextField ();
Textfield.setbounds (133, 147, 150, 25);
Contentpanel.add (TextField);
Textfield.setcolumns (10);
Textfield_1 = new JTextField ();
Textfield_1.setbounds (133, 182, 150, 25);
Contentpanel.add (textfield_1); Textfield_1.SetColumns (10);
JLabel Lblnewlabel = new JLabel ("Mailbox");
Lblnewlabel.setbounds (53, 151, 54, 15);
Contentpanel.add (Lblnewlabel);
JLabel lblnewlabel_1 = new JLabel ("password");
Lblnewlabel_1.setbounds (53, 194, 54, 15);
Contentpanel.add (Lblnewlabel_1);
JLabel lblnewlabel_2 = new JLabel ("new label");
Lblnewlabel_2.setbounds (0, 0, 360, 136);
ImageIcon icon=new ImageIcon (LoginDialog.class.getResource ("/res/login.jpg"));
Icon=imagescale.getimage (icon, Lblnewlabel_2.getwidth (), Lblnewlabel_2.getheight ());
Lblnewlabel_2.seticon ((icon));
Contentpanel.add (lblnewlabel_2);
JPanel panel = new JPanel (); Panel.setborder (new Titledborder (null, "\u6ce8\u518c\u7528\u6237", titledborder.leading, titledborder.top, NULL,
NULL));
Panel.setbounds (12, 259, 336, 221);
Contentpanel.add (panel);
Panel.setlayout (NULL);
JLabel lblnewlabel_3 = new JLabel ("Mailbox"); LBlnewlabel_3.setbounds (41, 29, 55, 18);
Panel.add (Lblnewlabel_3);
JLabel lblnewlabel_4 = new JLabel ("Authentication Code");
Lblnewlabel_4.setbounds (41, 85, 55, 18);
Panel.add (Lblnewlabel_4);
JLabel lblnewlabel_5 = new JLabel ("password");
Lblnewlabel_5.setbounds (41, 115, 55, 18);
Panel.add (lblnewlabel_5);
JLabel label = new JLabel ("Confirm password");
Label.setbounds (41, 145, 55, 18);
Panel.add (label);
Textfield_2 = new JTextField ();
Textfield_2.setbounds (123, 22, 150, 25);
Panel.add (textfield_2);
Textfield_2.setcolumns (10);
Textfield_3 = new JTextField ();
Textfield_3.setbounds (123, 80, 150, 25);
Panel.add (Textfield_3);
Textfield_3.setcolumns (10);
Textfield_4 = new JTextField ();
Textfield_4.setbounds (123, 113, 150, 25);
Panel.add (Textfield_4);
Textfield_4.setcolumns (10);
Textfield_5 = new JTextField (); Textfield_5.setbounds(123, 145, 150, 25);
Panel.add (textfield_5);
Textfield_5.setcolumns (10);
JButton btnnewbutton_2 = new JButton ("Send authentication Code");
Btnnewbutton_2.setbounds (123, 52, 83, 23);
Panel.add (btnnewbutton_2);
JButton btnnewbutton_3 = new JButton ("Cancel");
Btnnewbutton_3.setbounds (51, 182, 83, 27);
Panel.add (Btnnewbutton_3);
JButton btnnewbutton_4 = new JButton ("confirmation");
Btnnewbutton_4.setbounds (190, 182, 83, 27);
Panel.add (Btnnewbutton_4);
}
}
Tool Class Com.lsh.util.ImageScale
Package com.lsh.util;
Import Java.awt.Image;
Import Javax.swing.ImageIcon;
public class Imagescale {public
static ImageIcon getImage (ImageIcon icon,int width,int height) {
Image image= Icon.getimage (). getScaledInstance (width, height,image.scale_replicate);
Icon.setimage (image);
return icon;
}
Tool Class Com.lsh.util.WindowXY
package com.lsh.util;
Import java.awt.Dimension;
Import Java.awt.Point;
Import Java.awt.Toolkit;
public class Windowxy {public static point getxy (int w,int h) {Toolkit toolkit=toolkit.getdefaulttoolkit ();
int width=toolkit.getscreensize (). width;
int height=toolkit.getscreensize (). Height;
Return to New Point ((WIDTH-W)/2, (HEIGHT-H)/2);
public static point Getxy (Dimension Dimension) {return Getxy (dimension.width, dimension.height); }
}