java写一个登陆注册程序,用java写一个登陆注册界面代码

这篇博客展示了如何使用Java Swing库创建一个登录和注册界面。用户界面包含用户名和密码输入字段,以及登录和注册按钮。点击登录按钮会验证用户名和密码,而注册按钮则打开一个新的注册窗口。代码中还定义了用户信息类和数据存储类来管理用户数据。
摘要由CSDN通过智能技术生成

importjava.awt.GridLayout;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjava.util.ArrayList;

importjava.util.List;

importjavax.swing.JButton;

importjavax.swing.JFrame;

importjavax.swing.JLabel;

importjavax.swing.JOptionPane;

importjavax.swing.JPasswordField;

importjavax.swing.JTextField;

//登录窗体类

publicclassMainextendsJFrameimplementsActionListener,Runnable{

privatestaticfinallongserialVersionUID=1L;

protectedJLabellblPrompt,lblTime,lblUserName,lblPassword;

protectedJTextFieldtxtUserName;

protectedJPasswordFieldtxtPassword;

protectedJButtonbtnLogin,btnRegister;

protectedstaticThreadthread=null;

publicstaticvoidmain(String[]args){

Data.init();

MainfrmLogin=newMain();

thread=newThread(frmLogin);

thread.start();

}

publicMain(){

super("用户登录");

initComponent();

}

//初始化控件

publicvoidinitComponent(){

lblPrompt=newJLabel("登录剩余时间(秒):");

lblTime=newJLabel("60");

lblUserName=newJLabel("用户名:");

lblPassword=newJLabel("密码:");

txtUserName=newJTextField(10);

txtPassword=newJPasswordField(10);

btnLogin=newJButton("登录");

btnRegister=newJButton("注册");

btnLogin.addActionListener(this);

btnRegister.addActionListener(this);

this.setLayout(newGridLayout(4,2));

this.add(lblPrompt);

this.add(lblTime);

this.a

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值