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; 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
Randomness s1=new random ();//Generate Stochastic verification code
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);
SetVisible (TRUE);//Make the form visible
}
public static void Main (String args[])
{
New ZC ();
}
}
With the absolute layout of swing components in Java, the position and size of each module are adjusted to the best fit. Generates a four-bit verification code by generating a random number.
Ask the great God to teach you how to read and compare the verification code entered.
Make a simple landing window with Java and ask the Great God to teach