「java注册登录」java注册登录界面

博主:adminadmin 2022-11-29 17:57:07 62

今天给各位分享java注册登录的知识,其中也会对java注册登录界面进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

java使用面向对象写一个登录注册查询的功能

import java.util.Scanner;/**

* 采用面向对象的方式 写一个登录系统

* @author Administrator

*

*///用户信息class UserInfo{ public static String[] user = new String[10]; public static String[] passwd = new String[10];

public UserInfo() { this.user[0] = "test"; this.passwd[0] ="123456";

}

}//找回密码class ZhaoHui extends UserInfo{ public static void zhaohui() {

Scanner s = new Scanner(System.in);

System.out.println("请输入你要找回的用户名:");

String zname = s.nextLine(); for(int i=0;i2;i++) { if(user[i].equals(zname)) {

Scanner ss = new Scanner(System.in);

System.out.println("恭喜你!成功找回密码,请输入:"+"'张哥最帅'"+" 查看密码");

String zgzs = ss.nextLine();

if("张哥最帅".equals(zgzs)) {

System.out.println(passwd[i]);

}else {

System.out.println("请输正确!");

}

}else if(user[i]!=zname){

System.out.println("用户名不存在!"); return;

}

break;

}

}

}//修改密码 class XiuGai extends UserInfo{ public static void xiugai() {

Scanner s =new Scanner(System.in);

System.out.println("请输入您要修改的密码:");

String xpasswd = s.nextLine(); for(int i=0;i2;i++) {

passwd[i] = xpasswd; if(xpasswd.equals(passwd[i])) {

System.out.println("恭喜你,修改成功!"); break;

}else {

System.out.println("修改密码失败"); break;

}

}

}

}//查询用户class ChaXun extends UserInfo{

public static void select() { for(int i=0;i2;i++) {

System.out.println("当前用户:"+user[i] +"\n"+ "当前密码:"+passwd[i] );

i++; break;

}

}

}//注册class ZhuCe extends UserInfo{

public static void regist() {

Scanner ss = new Scanner(System.in);

System.out.println("请输入用户名:");

String suser = ss.nextLine();

System.out.println("请输入密码:");

String spasswd = ss.nextLine();

for(int i=0;iuser.length;i++) {

user[i] = suser;

passwd[i] = spasswd;

System.out.println("注册成功!"); break;

}

}

}//登录class Loginc extends UserInfo{

public static void login() { int flag = 1;

Scanner scanner = new Scanner(System.in);

System.out.println("请输入用户名:");

String users = scanner.nextLine();

System.out.println("请输入密码:");

String passwds = scanner.nextLine();

for(int i=0;iUserInfo.user.length;i++) { if(user[i].equals(users) passwd[i].equals(passwds)) {

System.out.println("登陆成功!"); break;

}

System.out.println("登陆失败!"); break;

}

}

}//主界面class ZhuJieMian{ public static void Start() {

Loginc Loginc = new Loginc();

ZhuCe ZhuCe = new ZhuCe();

ChaXun ChaXun = new ChaXun();

XiuGai XiuGai = new XiuGai();

ZhaoHui ZhaoHui = new ZhaoHui();

Scanner s = new Scanner(System.in); while(true) {

System.out.println("|"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+"\t"+"|");

System.out.println("|"+"\t" + "测试用户名:test 测试密码:123456" + "\t"+ "\t"+ "\t"+ "\t"+"|");

System.out.println("|" + "\t"+ "请输入[1-5]进行操作 1.登录|2.注册|3.查询当前用户|4.修改密码|5.找回密码 " + "\t"+"|");

System.out.print("请输入:"); int temp = s.nextInt();

switch(temp) { case 1:Loginc.login(); break; case 2:ZhuCe.regist();; break; case 3:ChaXun.select();; break; case 4:XiuGai.xiugai();; break; case 5:ZhaoHui.zhaohui();; break; default:System.out.println("错误!请重写输入正确的数字进行操作!");

}

}

}

}public class LoginTest { public static void main(String[] args) {

ZhuJieMian zjm = new ZhuJieMian();

zjm.Start();

}

}

性能测试中如何使用java批量注册登录账户

性能测试中示例代码使用java批量注册登录账户。

性能测试过程中所需的测试数据,以登录为例,为了更真实的模 批量读取注册。

Java登录注册功能实现代码解析,文中通示例代码,每个用户信息都是唯一的,所以可以借助Set的特性来操作用户信息的存放。

java语言实现用户注册和登录

//这个是我写的,里面有连接数据库的部分。你可以拿去参考一下

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class LoginFrm extends JFrame implements ActionListener// throws Exception

{

JLabel lbl1 = new JLabel("用户名:");

JLabel lbl2 = new JLabel("密码:");

JTextField txt = new JTextField(5);

JPasswordField pf = new JPasswordField();

JButton btn1 = new JButton("确定");

JButton btn2 = new JButton("取消");

public LoginFrm() {

this.setTitle("登陆");

JPanel jp = (JPanel) this.getContentPane();

jp.setLayout(new GridLayout(3, 2, 5, 5));

jp.add(lbl1);

jp.add(txt);

jp.add(lbl2);

jp.add(pf);

jp.add(btn1);

jp.add(btn2);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent ae) {

if (ae.getSource() == btn1) {

try {

Class.forName("com.mysql.jdbc.Driver");// mysql数据库

Connection con = DriverManager.getConnection(

"jdbc:mysql://localhost/Car_zl", "root", "1");// 数据库名为Car_zl,密码为1

System.out.println("com : "+ con);

Statement cmd = con.createStatement();

String sql = "select * from user where User_ID='"

+ txt.getText() + "' and User_ps='"

+ pf.getText() + "'" ;

ResultSet rs = cmd

.executeQuery(sql);// 表名为user,user_ID和User_ps是存放用户名和密码的字段名

if (rs.next()) {

JOptionPane.showMessageDialog(null, "登陆成功!");

} else

JOptionPane.showMessageDialog(null, "用户名或密码错误!");

} catch (Exception ex) {

}

if (ae.getSource() == btn2) {

System.out.println("1111111111111");

//txt.setText("");

//pf.setText("");

System.exit(0);

}

}

}

public static void main(String arg[]) {

JFrame.setDefaultLookAndFeelDecorated(true);

LoginFrm frm = new LoginFrm();

frm.setSize(400, 200);

frm.setVisible(true);

}

}

用Java编写注册登录程序

什么都不说了 直接给你代码吧

package com.moliying.ui;

import java.awt.BorderLayout;

import java.awt.Container;

import java.awt.FlowLayout;

import java.awt.List;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedWriter;

import java.io.FileOutputStream;

import java.io.OutputStreamWriter;

import java.util.ArrayList;

import java.util.Arrays;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

public class Login {

private JFrame frame = new JFrame("登录");

private Container c = frame.getContentPane();

private JTextField username = new JTextField();

private JPasswordField password = new JPasswordField();

private JButton ok = new JButton("确定");

private JButton cancel = new JButton("取消");

public Login() {

frame.setSize(300, 200);

frame.setBounds(450, 300, 300, 200);

c.setLayout(new BorderLayout());

initFrame();

frame.setVisible(true);

}

private void initFrame() {

// 顶部

JPanel titlePanel = new JPanel();

titlePanel.setLayout(new FlowLayout());

titlePanel.add(new JLabel("系统管理员登录"));

c.add(titlePanel, "North");

// 中部表单

JPanel fieldPanel = new JPanel();

fieldPanel.setLayout(null);

JLabel a1 = new JLabel("用户名:");

a1.setBounds(50, 20, 50, 20);

JLabel a2 = new JLabel("密 码:");

a2.setBounds(50, 60, 50, 20);

fieldPanel.add(a1);

fieldPanel.add(a2);

username.setBounds(110, 20, 120, 20);

password.setBounds(110, 60, 120, 20);

fieldPanel.add(username);

fieldPanel.add(password);

c.add(fieldPanel, "Center");

// 底部按钮

JPanel buttonPanel = new JPanel();

buttonPanel.setLayout(new FlowLayout());

buttonPanel.add(ok);

buttonPanel.add(cancel);

c.add(buttonPanel, "South");

ok.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

System.out.println(username.getText().toString());

}

});

cancel.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

frame.setVisible(false);

}

});

}

public static void main(String[] args) {

// new Login();

String ss = "abbabbbaabbbccba";

System.out.println(ss.split("b").length);

}

}

用java编程实现用户注册并进行登录操作

String username = "",password = "",passwordagain = ""; // 定义用户名和密码

将该变量等于为全局变量 或局部变量即可

关于java注册登录和java注册登录界面的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-29,除非注明,否则均为首码项目网原创文章,转载请注明出处。