Make landing page with absolute layout (improved)

Source: Internet
Author: User

Import Java.awt.Container;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;
Import Java.util.Random;

Import Javax.swing.JButton;
Import Javax.swing.JFrame;
Import Javax.swing.JLabel;
Import Javax.swing.JOptionPane;
Import Javax.swing.JPasswordField;
Import Javax.swing.JTextField;
Import javax.swing.WindowConstants;
Load Package Swing
@SuppressWarnings ("Serial")
public class ZC extends jframe{
Public ZC ()
{
String[] a={"A", "s", "D", "F", "G", "H", "J", "K", "L", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "Z", "X", "C", "V", "B", "N" , "M", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
Settitle ("Welcome login");//Set the form title
SetLayout (null);//form cancels layout manager settings
SetBounds (0,0,250,350);//location and size of the position form
@SuppressWarnings ("unused")
Container C=getcontentpane ();//Create a container object
Random s1=new random ();
Random s2=new random ();
Random s3=new random ();
Random s4=new random ();
int i,j,k,l;
I=s1.nextint (35);
J=s2.nextint (35);
K=s3.nextint (35);
L=s4.nextint (35);
JLabel yh=new JLabel ("User name");//create a user name tag
JLabel mm=new JLabel ("password");//create a password tag
JLabel yz=new JLabel ("Verification Code");//create a Verification code label
JTextField yh1=new JTextField (NULL);//Add a text box
JPasswordField mm1=new JPasswordField (NULL);//Add a password box
JTextField yz1=new JTextField (NULL);//Add a text box
JLabel yz2=new JLabel (A[i]+a[j]+a[k]+a[l]);
JButton b1=new JButton ("Landing");
JButton b2=new JButton ("Cancel");
Yh.setbounds (10,30,80,30);//username location and size
Mm.setbounds (10,75,80,30);//Password label location and size
Yz.setbounds (10,120,80,30);//Verification Code label location and size
Yh1.setbounds (60,30,100,30);//User name box location and size
Mm1.setbounds (60,75,100,30);//Password box location and size
Yz1.setbounds (60,120,100,30);//Verify the Code box position and size
Yz2.setbounds (70,170,80,30);
B1.setbounds (20,220,80,30);
B2.setbounds (120,220,80,30);
C.add (YH);//Tell labels and boxes to add to the container
C.add (mm);
C.add (YZ);
C.add (YH1);
C.add (MM1);
C.add (YZ1);

C.add (B2);
C.add (YZ2);


C.add (B1);
Class YZ implements ActionListener
{
public void actionperformed (ActionEvent c)
{
String S1=yh1.gettext (). toString ();
String S2=mm1.gettext (). toString ();
String S3=yz1.gettext (). toString ();
String s4=string.valueof (A[i]+a[j]+a[k]+a[l]);
if (S1.equals (""))//user name not entered
Joptionpane.showmessagedialog (NULL, "Please enter user name");
@SuppressWarnings ("deprecation")

else if (S2.equals ("))//Password not entered
Joptionpane.showmessagedialog (NULL, "Please enter password");
else if (S3.equals ("))//No verification code entered
Joptionpane.showmessagedialog (NULL, "Please enter a verification code");
else if (S3.equals (S4))
Joptionpane.showmessagedialog (NULL, "login successful");
else//Verification Code Error
Joptionpane.showmessagedialog (NULL, "CAPTCHA error");
}
}
Class GB implements ActionListener
{
public void actionperformed (ActionEvent c)
{
System.exit (0);
}
}
B1.addactionlistener (New YZ ());
B2.addactionlistener (New GB ());
SetVisible (TRUE);//Make the form visible
}
public static void Main (String args[])
{
New ZC ();
}

Make landing page with absolute layout (improved)

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.