① 性能測試中如何使用java批量注冊登錄賬戶
性能測試中示例代碼使用java批量注冊登錄賬戶。
性能測試過程中所需的測試數據,以登錄為例,為了更真實的模 批量讀取注冊。
Java登錄注冊功能實現代碼解析,文中通示例代碼,每個用戶信息都是唯一的,所以可以藉助Set的特性來操作用戶信息的存放。
② java不使用數組,編寫一個注冊登錄系統
需要使用後台資料庫嗎?不需要資料庫的話代碼如下(控制台):
import java.util.Scanner;
public class test {
private static String loginName="",pwd="";//loginName用來存儲注冊的登錄名,pwd用來存儲注冊的密碼
private static Scanner input = new Scanner(System.in);
//注冊時輸入密碼的方法
private static void inputPWD(){
String upwd,rpwd;
System.out.print("請輸入密碼:");
upwd = input.next();
System.out.print("請輸入確認密碼:");
rpwd=input.next();
if (!upwd.equals(rpwd)) {
System.out.println("密碼和確認密碼不一致,請重新輸入!\n");
inputPWD();
}else {
System.out.println("注冊成功!");
pwd = upwd;
}
}
//注冊用戶名和密碼的方法
private static void region(){
System.out.print("請輸入用戶名:");
loginName = input.next();
inputPWD();
}
//登陸的方法
private static void loign(){
String lname,lpwd;
System.out.print("請輸入用戶名:");
lname=input.next();
System.out.print("請輸入密碼:");
lpwd=input.next();
if (lname.equals(loginName)&&lpwd.equals(pwd)) {
System.out.println("登陸成功!");
}else{
System.out.println("用戶名或密碼錯誤,請重新輸入!\n");
loign();
}
}
//顯示選擇菜單的方法
private static void showMenu(){
System.out.println("1.用戶注冊");
System.out.println("2.用戶登陸");
System.out.println("3.退出系統");
System.out.print("請輸入你的選擇:");
String choose = input.next();
if (choose.equalsIgnoreCase("1")) {
region();
System.out.println("");
showMenu();
}else if (choose.equalsIgnoreCase("2")) {
if (loginName.equalsIgnoreCase("")) {
System.out.print("沒有用戶,請先注冊!\n\n");
showMenu();
}else{
loign();
}
}else if(choose.equalsIgnoreCase("3")){
System.out.println("系統退出成功!");
}else {
System.out.println("非法輸入!\n");
showMenu();
}
}
public static void main(String[] args) {
showMenu();
}
}
③ java 中 有1.注冊 2.登錄 3.退出功能 我輸入一 就實現注冊然後返回 選擇2就能登錄 提供以下代碼
不要復雜化,代碼要簡單化,需求是什麼就寫什麼。參考如下:
//用於保存用戶帳戶信息的數組
Scannerscanner=newScanner(System.in);
String[]user=newString[2];
while(true){
//銀行主界面
System.out.println("------------------------------歡迎來到銀行------------------------------");
System.out.println("請選擇編號: 1:注冊 2:登錄 3退出");
intnum=scanner.nextInt();
switch(num){
case1:
//注冊
System.out.println("請輸入您的賬戶名:");
Stringname=scanner.next();
user[0]=name;
System.out.println("請輸入您的密碼:");
Stringpassword=scanner.next();
user[1]=password;
System.out.println("注冊成功!");
//返回主界面
break;
case2:
while(true){
//登錄
System.out.println("請輸入您的帳戶名:");
StringuserName=scanner.next();
System.out.println("請輸入您的密碼:");
StringuserPwd=scanner.next();
//判斷輸入的用戶名是否在數組中存在(判斷該用戶是否注冊)
if(user[0].equals(userName)&&user[1].equals(userPwd)){
System.out.println("-----------登錄成功,請選擇您要辦理的業務------------");
break;
}else{
System.out.println("-----------用戶名或密碼錯誤,請重新輸入------------");//返回到登錄界面
continue;
}
}
break;
case3:
//退出系統程序結束
System.out.println("退出成功,歡迎再次使用");
System.exit(0);
break;
default:
break;
}
}
④ 用JAVA編寫一個用戶或注冊登錄界面。請哪位高手能夠寫下具體的代碼,謝謝
效果圖
<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<title>先鋒圖書館管理系統-登錄</title>
<style>
*{
margin:0;
padding:0;
list-style:none;
}
#top{
width:1000px;
height:95px;
margin:0auto;
margin-top:25px;
}
#top_top{
width:1000px;
height:65px;
background:deepskyblue;
}
#top_top_left{
width:300px;
height:65px;
float:left;
}
#top_top_left>label{
width:200px;
height:65px;
color:white;
float:right;
}
#top_top_left>#a2{
padding-left:10px;
padding-top:20px;
font-size:16px;
}
#top_bottom{
width:1000px;
height:30px;
}
#top_bottom_left{
width:340px;
height:30px;
line-height:30px;
font-size:12px;
background:skyblue;
color:white;
text-indent:2em;
float:left;
}
#top_bottom_right{
width:660px;
height:30px;
line-height:30px;
font-size:12px;
color:blueviolet;
text-align:center;
float:right;
background:lightskyblue;
}
#content{
width:1000px;
height:600px;
margin:0auto;
background:#587FBA;
}
#content>#text{
width:1000px;
height:50px;
line-height:50px;
padding-top:100px;
font-size:36px;
font-family:"楷體";
font-weight:bold;
text-align:center;
}
#content>#login{
width:480px;
height:210px;
margin-top:20px;
margin-left:260px;
background:#85A0CB;
}
#content>#login>img{
float:left;
}
#content>#login>#select{
width:305px;
height:210px;
float:right;
}
#content>#login>#select>div{
width:230;
height:30px;
margin-left:30px;
}
#content>#login>#select>#d1{
margin-top:30px;
margin-bottom:3px;
}
#content>#login>#select>p{
font-size:14px;
margin-left:95px;
}
#bottom{
width:1000px;
height:35px;
line-height:35px;
margin:0auto;
background:deepskyblue;
text-align:center;
color:white;
}
</style>
</head>
<body>
<divid="top">
<divid="top_top">
<divid="top_top_left">
<imgsrc="img/test/a13.png"width="78px"height="65px"><labelid="a2">先鋒圖書館系統管理平台</label>
</div>
</div>
<divid="top_bottom">
<divid="top_bottom_left">當前位置:首頁>系統管理>登錄</div>
<divid="top_bottom_right">當前時間:<labelid="lable"></label></div>
</div>
</div>
<divid="content">
<divid="text">歡迎登錄先鋒圖書館管理系統</div>
<divid="login">
<imgsrc="img/test/a14.png"width="175px"height="210px"/>
<formid="select">
<divid="d1">用戶名: <inputtype="text"/></div>
<div>密 碼: <inputtype="password"/></div>
<p>
<inputtype="radio"name="user"value="read"/>讀者
<inputtype="radio"name="user"value="admin"/>管理員
</p><br/>
<p>
<inputtype="button"value="確定"style="width:50px;"onclick="put()"/>
<inputtype="reset"value="重置"style="width:50px;"/>
</p>
</form>
</div>
</div>
<divid="bottom">欣欣科技有限公司版權所有</div>
</body>
<scripttype="text/javascript"src="JQuery/jquery.js"></script>
<scripttype="text/javascript"src="js/GetCurrentTime.js"></script>
<script>
//驗證用戶名和密碼
functionput(){
vard=$("#select>div>input");//獲取用戶名和密碼
varname=d[0].value;
varpass=d[1].value;
varuser=null;
varr=document.getElementsByName("user");//獲取用戶類型
for(i=0;i<r.length;i++){
if(r[i].checked){
user=r[i].value;
}
}
//console.log(name+","+pass+","+user);//輸出測試
if(user==null){
window.alert("請選擇用戶類型!");
}elseif(user=="admin"&&name!="admin"){
window.alter("用戶名錯誤!");
}elseif(user=="admin"&&name=="admin"&&pass!="123456"){
window.alert("密碼錯誤!");
}elseif(name=="admin"&&pass=="123456"&&user=="admin"){
window.location.href="work_02_welcome.html";//在js中在本頁面中打開新鏈接
}else{
window.alert("用戶名錯誤");
}
}
</script>
</html>
⑤ 登陸界面的java代碼怎麼寫
具體框架使用jframe,文本框組件:JTextField;密碼框組件:JPasswordField;標簽組件:JLabel;復選框組件:JCheckBox;單選框組件:JRadioButton;按鈕組件JButton。
登錄界面:
Swing 是一個為Java設計的GUI工具包。
Swing是JAVA基礎類的一部分。
Swing包括了圖形用戶界面(GUI)器件如:文本框,按鈕,分隔窗格和表。
Swing提供許多比AWT更好的屏幕顯示元素。它們用純Java寫成,所以同Java本身一樣可以跨平台運行,這一點不像AWT。它們是JFC的一部分。它們支持可更換的面板和主題(各種操作系統默認的特有主題),然而不是真的使用原生平台提供的設備,而是僅僅在表面上模仿它們。這意味著你可以在任意平台上使用JAVA支持的任意麵板。輕量級組件的缺點則是執行速度較慢,優點就是可以在所有平台上採用統一的行為。
概念解析:
JFrame– java的GUI程序的基本思路是以JFrame為基礎,它是屏幕上window的對象,能夠最大化、最小化、關閉。
JPanel– Java圖形用戶界面(GUI)工具包swing中的面板容器類,包含在javax.swing 包中,可以進行嵌套,功能是對窗體中具有相同邏輯功能的組件進行組合,是一種輕量級容器,可以加入到JFrame窗體中。。
JLabel– JLabel 對象可以顯示文本、圖像或同時顯示二者。可以通過設置垂直和水平對齊方式,指定標簽顯示區中標簽內容在何處對齊。默認情況下,標簽在其顯示區內垂直居中對齊。默認情況下,只顯示文本的標簽是開始邊對齊;而只顯示圖像的標簽則水平居中對齊。
JTextField–一個輕量級組件,它允許編輯單行文本。
JPasswordField– 允許我們輸入了一行字像輸入框,但隱藏星號(*) 或點創建密碼(密碼)
JButton– JButton 類的實例。用於創建按鈕類似實例中的 "Login"。
⑥ java編寫一個登陸和注冊信息的源代碼,最簡單的就可以,不需要資料庫的那種
你這個不用資料庫真的是有點難搞
我寫了個用集合存儲的,你看看,能否幫上你
java.util.List<String>list=newArrayList<String>();
list.add("qq=123");//存儲的時候用(用戶名=密碼)的形式
list.add("ww=456");
Stringusername="qq";
Stringpassword="123";
for(inti=0;i<list.size();i++){
Stringnum=username+"="+password;
if(num.equals(list.get(i))){
System.out.println("登錄成功");
break;
}
}
⑦ 我用Eclipse java EE做了一個登錄,注冊的 窗口,點登錄和注冊之後的窗口跳轉的代碼怎麼寫
window.open(URL,name,features,replace)
描述
URL 一個可選的字元串,聲明了要在新窗口中顯示的文檔的 URL。如果省略了這個參數,或者它的值是空字元串,那麼新窗口就不會顯示任何文檔。
name 一個可選的字元串,該字元串是一個由逗號分隔的特徵列表,其中包括數字、字母和下劃線,該字元聲明了新窗口的名稱。這個名稱可以用作標記 <a> 和 <form> 的屬性 target 的值。如果該參數指定了一個已經存在的窗口,那麼 open() 方法就不再創建一個新窗口,而只是返回對指定窗口的引用。在這種情況下,features 將被忽略。
features 一個可選的字元串,聲明了新窗口要顯示的標准瀏覽器的特徵。如果省略該參數,新窗口將具有所有標准特徵。在窗口特徵這個表格中,我們對該字元串的格式進行了詳細的說明。
replace
一個可選的布爾值。規定了裝載到窗口的 URL 是在窗口的瀏覽歷史中創建一個新條目,還是替換瀏覽歷史中的當前條目。支持下面的值:
true - URL 替換瀏覽歷史中的當前條目。
false - URL 在瀏覽歷史中創建新的條目。
例子:
<script type="text/javascript">
function aa(){
window.open('你自己的頁面名稱.html','name');
}
</script>
<input type="button" value="JS打開新頁面" onclick="aa()" />
⑧ 用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 登錄注冊界面代碼怎麼寫不鏈接資料庫。不用mysql !
給你提供個思路吧
1、注冊界面把注冊的人的用戶名和密碼存儲到本地的一個txt文件中
2、登錄時比較登錄輸入的用戶名和密碼和txt文件中的是否一致,如果一致就允許登錄,不一致提示異常
⑩ 求JAVA實現用戶登錄界面代碼
你要先學會截圖哦,你發的看不清楚,重新寫了一個你參考參考!
import java.awt.GridLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class Day30A extends JFrame {
private static final long serialVersionUID = 1L;
private JLabel labelName,labelId,labelPass,labelMoney,labelSelect,labelCar;
private JComboBox<String> jcb;
private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7;
private ButtonGroup btg;
private JRadioButton jr1,jr2;
Day30A(){
this.setTitle("注冊賬戶");
this.setLayout(new GridLayout(7,1));
this.setSize(300,280);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
init();
this.setVisible(true);
}
private void init() {
String str="卡片類型1,卡片類型2,卡片類型3,卡片類型4,卡片類型5";
jcb=new JComboBox<>(str.split(","));
labelId=new JLabel("賬號: ");
labelName=new JLabel("姓名: ");
labelPass=new JLabel("密碼: ");
labelMoney=new JLabel("開戶金額:");
labelSelect=new JLabel("存款類型:");
labelCar=new JLabel("卡片類型:");
addFun1();
addFun2();
}
private void addFun2() {
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.add(jp4);
this.add(jp5);
this.add(jp6);
this.add(jp7);
}
private void addFun1() {
jp1=new JPanel();
jp1.add(labelId);
jp1.add(new JTextField(15));
jp2=new JPanel();
jp2.add(labelName);
jp2.add(new JTextField(15));
jp3=new JPanel();
jp3.add(labelPass);
jp3.add(new JTextField(15));
jp4=new JPanel();
jp4.add(labelMoney);
jp4.add(new JTextField(13));
jp5=new JPanel();
jp5.add(labelSelect);
btg=new ButtonGroup();
jr1=new JRadioButton("定期");
jr2=new JRadioButton("活期",true);
btg.add(jr1);
btg.add(jr2);
jp5.add(jr1);
jp5.add(jr2);
jp6=new JPanel();
jp6.add(labelCar);
jp6.add(jcb);
jp7=new JPanel();
jp7.add(new JButton("確定"));
jp7.add(new JButton("取消"));
}
public static void main(String[] args) {
new Day30A();
}
}