展开全部
import java.awt.*;
import javax.swing.*;
public class test extends JFrame
{
JPanel jpanel1,jpanel2,jpanel3;
JButton button1,button2;
JLabel label1,label2;
JTextField jtextField;
JPasswordField passwordField;
public static void main(String[] args)
{
32313133353236313431303231363533e78988e69d8331333365646265test lx=new test();
}
test()
{
jpanel1=new JPanel();
jpanel2=new JPanel();
jpanel3=new JPanel();
label1=new JLabel("用户名");
label2=new JLabel("密 码");
button1=new JButton("登录");
button2=new JButton("取消");
jtextField=new JTextField(10);
passwordField=new JPasswordField(10);
this.setLayout(new GridLayout(3,1));
jpanel1.add(label1); jpanel1.add(jtextField);
jpanel2.add(label2); jpanel2.add(passwordField);
jpanel3.add(button1); jpanel3.add(button2);
this.add(jpanel1);
this.add(jpanel2);
this.add(jpanel3);
this.setTitle("登录演示");
this.setSize(300,200);
this.setLocation(500,300);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
简单一点的:import java.util.Scanner;
public class test{
public static long password = 123456789L;
public static void main(String[] args){
Scanner in = new Scanner(System.in);
boolean flag = false;
long input = 0L;
while(!flag){
System.out.println("请输入密码:");
try{
input = in.nextLong();
}catch(Exception e){
e.printStackTrace();
}
flag = (input ==password);
}
System.out.println("欢迎登录!");
}
}
//最后,欢迎关注我的微信公众号微阅窗,关于阅读的。。。。