欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java賬號(hào)密碼注冊(cè)代碼,java注冊(cè)賬號(hào)的代碼

用Java編寫用戶注冊(cè)界面,包含:用戶名、密碼、密碼確認(rèn)、郵箱,以及注冊(cè)和清空兩個(gè)按鈕。求高手,感謝!

界面建議用可視化來(lái)做,美觀且便捷。下面這個(gè)是完全用代碼寫的,僅供參考。

創(chuàng)新互聯(lián)公司網(wǎng)絡(luò)公司擁有十余年的成都網(wǎng)站開發(fā)建設(shè)經(jīng)驗(yàn),上千多家客戶的共同信賴。提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、網(wǎng)站開發(fā)、網(wǎng)站定制、賣鏈接、建網(wǎng)站、網(wǎng)站搭建、響應(yīng)式網(wǎng)站開發(fā)、網(wǎng)頁(yè)設(shè)計(jì)師打造企業(yè)風(fēng)格,提供周到的售前咨詢和貼心的售后服務(wù)

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

import java.sql.*;

public class Register extends JFrame {

JLabel jl1 = new JLabel("用戶名");

JTextField jt1 = new JTextField();

JLabel jl2 = new JLabel("郵箱");

JTextField jt2 = new JTextField();

JLabel jl3 = new JLabel("密碼");

JPasswordField jpw1 = new JPasswordField();

JLabel jl4 = new JLabel("密碼確認(rèn)");

JPasswordField jpw2 = new JPasswordField();

JButton register = new JButton("注冊(cè)");

JButton clean = new JButton("清空");

public Register(){

setLayout(new GridLayout(5,2));

add(jl1);

add(jt1);

add(jl2);

add(jt2);

add(jl3);

add(jpw1);

add(jl4);

add(jpw2);

add(register);

add(clean);

String name = jt1.getText();

String email = jt2.getText();

String pw = jpw1.getText();

register.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

try{

Class.forName("com.mysql.jdbc.Driver");

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/db","root","");

Statement sta = con.createStatement();

sta.executeUpdate("INSERT INTO register VALUES(name,email,pw)");

JOptionPane.showMessageDialog(null,"注冊(cè)成功","提示",JOptionPane.INFORMATION_MESSAGE);

}

catch(Exception ex){

ex.getStackTrace();

}

}

});

clean.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e){

jt1.setText("");

jt2.setText("");

jpw1.setText("");

jpw2.setText("");

}

});

}

public static void main(String[] args){

Register frame = new Register();

frame.setTitle("用戶注冊(cè)");

frame.setLocationRelativeTo(null);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(400,400);

frame.setVisible(true);

}

}

用JAVA編寫一個(gè)用戶或注冊(cè)登錄界面。請(qǐng)哪位高手能夠?qū)懴戮唧w的代碼,謝謝

效果圖

代碼

!DOCTYPE?html

html

head

meta?charset="UTF-8"

title先鋒圖書館管理系統(tǒng)-登錄/title

style

*{

margin:?0;

padding:?0;

list-style:?none;

}

#top{

width:?1000px;

height:?95px;

margin:?0?auto;

margin-top:?25px;

}

#top_top{

width:?1000px;

height:?65px;

background:?deepskyblue;

}

#top_top_left{

width:?300px;

height:?65px;

float:?left;

}

#top_top_leftlabel{

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:?0?auto;

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#loginimg{

float:?left;

}

#content#login#select{

width:?305px;

height:?210px;

float:?right;

}

#content#login#selectdiv{

width:?230;

height:?30px;

margin-left:?30px;

}

#content#login#select#d1{

margin-top:30px;

margin-bottom:?3px;

}

#content#login#selectp{

font-size:?14px;

margin-left:?95px;

}

#bottom{

width:?1000px;

height:?35px;

line-height:?35px;

margin:?0?auto;

background:?deepskyblue;

text-align:?center;

color:?white;

}

/style

/head

body

div?id="top"

div?id="top_top"

div?id="top_top_left"

img?src="img/test/a13.png"?width="78px"?height="65px"label?id="a2"先鋒圖書館系統(tǒng)管理平臺(tái)/label

/div

/div

div?id="top_bottom"

div?id="top_bottom_left"當(dāng)前位置?:?首頁(yè)??系統(tǒng)管理??登錄/div

div?id="top_bottom_right"當(dāng)前時(shí)間?:?label?id="lable"/label/div

/div

/div

div?id="content"

div?id="text"歡迎登錄先鋒圖書館管理系統(tǒng)/div

div?id="login"

img?src="img/test/a14.png"??width="175px"?height="210px"/

form?id="select"

div?id="d1"用戶名:?nbsp;nbsp;input?type="text"?//div

div密????nbsp;?碼:?nbsp;nbsp;input?type="password"?//div

p

input?type="radio"?name="user"?value="read"/讀者nbsp;nbsp;nbsp;nbsp;

input?type="radio"?name="user"?value="admin"/管理員

/pbr/

p

input?type="button"?value="確定"?style="width:?50px;"?onclick="put()"/nbsp;nbsp;nbsp;nbsp;

input?type="reset"?value="重置"?style="width:?50px;"/

/p

/form

/div

/div

div?id="bottom"欣欣科技有限公司版權(quán)所有/div

/body

script?type="text/javascript"?src="JQuery/jquery.js"/script

script?type="text/javascript"?src="js/GetCurrentTime.js"/script

script

//驗(yàn)證用戶名和密碼

function?put(){

var?d?=?$("#selectdivinput");//獲取用戶名和密碼

var?name?=?d[0].value;

var?pass?=?d[1].value;

var?user?=?null;

var?r?=?document.getElementsByName("user");//獲取用戶類型

for(i=0;ir.length;i++){

if(r[i].checked){

user=r[i].value;

}

}

//console.log(name?+?","?+pass?+?","?+user);//輸出測(cè)試

if(user==null){

window.alert("請(qǐng)選擇用戶類型!");

}else?if(user=="admin"??name!="admin"){

window.alter("用戶名錯(cuò)誤!");

}else?if(user=="admin"??name=="admin"??pass!="123456"){

window.alert("密碼錯(cuò)誤!");

}else?if(name=="admin"??pass=="123456"??user=="admin"){

window.location.href="work_02_welcome.html";//在js中在本頁(yè)面中打開新鏈接

}else{

window.alert("用戶名錯(cuò)誤");

}

}

/script

/html

怎樣用java設(shè)置帳號(hào)和密碼

public class User{

//定義私有屬性 ?用戶名和密碼

private String userName;

private String password;

public User(String userName,String password){

this.userName=userName;

this.password=password;

}

//私有屬性的set ?get 方法

public void setUserName(String userName){

this.userName=userName;

}

public void setPassword(String password){

this.password=password; ?

}

public String getUserName(){

return this.userName;

}

public String getPassword(){

return this.password;

}

//用來(lái)判斷用戶名和密碼是否正確

public boolean panDuan(){

if("用戶名".equals(this.userName)"密碼".equals(this.password)){

? ? ?System.out.println("登入成功!");

? ? return true;

?}else{

? ? System.out.println("登入失??!");

? ?return false;

?}

}

public static void main (String[] args){

System.out.println("請(qǐng)輸入用戶名:");

scanner sc=new scanner(System.in);

String userName=sc.nextLine();

System.out.println("請(qǐng)輸入密碼:");

String password=sc.nextLine();

User u=new User(userName,password);

u.panDuan();

}

}

補(bǔ)充:Java是一種可以撰寫跨平臺(tái)應(yīng)用程序的面向?qū)ο蟮某绦蛟O(shè)計(jì)語(yǔ)言。Java 技術(shù)具有卓越的通用性、高效性、平臺(tái)移植性和安全性,廣泛應(yīng)用于PC、數(shù)據(jù)中心、游戲控制臺(tái)、科學(xué)超級(jí)計(jì)算機(jī)、移動(dòng)電話和互聯(lián)網(wǎng),同時(shí)擁有全球最大的開發(fā)者專業(yè)社群。

用java編程實(shí)現(xiàn)用戶注冊(cè)并進(jìn)行登錄操作

String username = "",password = "",passwordagain = ""; // 定義用戶名和密碼

將該變量等于為全局變量 或局部變量即可

java語(yǔ)言實(shí)現(xiàn)用戶注冊(cè)和登錄

//這個(gè)是我寫的,里面有連接數(shù)據(jù)庫(kù)的部分。你可以拿去參考一下

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數(shù)據(jù)庫(kù)

Connection con = DriverManager.getConnection(

"jdbc:mysql://localhost/Car_zl", "root", "1");// 數(shù)據(jù)庫(kù)名為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, "用戶名或密碼錯(cuò)誤!");

} 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);

}

}

新聞標(biāo)題:java賬號(hào)密碼注冊(cè)代碼,java注冊(cè)賬號(hào)的代碼
網(wǎng)頁(yè)鏈接:http://chinadenli.net/article32/hesgpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、App開發(fā)、手機(jī)網(wǎng)站建設(shè)、、動(dòng)態(tài)網(wǎng)站、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司