真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼實(shí)現(xiàn)密碼驗(yàn)證 java輸入密碼驗(yàn)證

JAVA 設(shè)計(jì)swing登錄界面驗(yàn)證用戶名密碼

應(yīng)用的還是web的啊..

為湘鄉(xiāng)等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及湘鄉(xiāng)網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、湘鄉(xiāng)網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

我給你寫(xiě)了個(gè)應(yīng)用的哈

你在C盤(pán)建個(gè)test.txt文件

里面寫(xiě)

username:用戶名(這里可以隨便寫(xiě)哈)

password:同上哈

注意是要換行的哦。。

比如

username:tiger

password:tiger

然后你建個(gè)Login的類

然后把下面的代碼弄進(jìn)去

運(yùn)行就是了

注意登陸的時(shí)候你文件里面設(shè)定的什么用戶名和密碼就輸入什么哈

輸入錯(cuò)誤就會(huì)提示輸入錯(cuò)誤的

import java.io.BufferedReader;

import java.io.FileReader;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

/**

*

* @author thinkpad

*/

public class Login extends javax.swing.JFrame {

/** Creates new form Login */

private static String username;

private static String password;

public Login() {

initComponents();

try {

BufferedReader br = new BufferedReader(new FileReader("C:\\test.txt"));

username = br.readLine().split("\\:")[1];

password = br.readLine().split("\\:")[1];

System.out.println(username + password);

} catch(Exception e) {

e.printStackTrace();

}

}

/** This method is called from within the constructor to

* initialize the form.

* WARNING: Do NOT modify this code. The content of this method is

* always regenerated by the Form Editor.

*/

@SuppressWarnings("unchecked")

// editor-fold defaultstate="collapsed" desc="Generated Code"

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jPasswordField1 = new javax.swing.JPasswordField();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setFont(new java.awt.Font("宋體", 0, 18)); // NOI18N

jLabel1.setText("Login");

jLabel2.setText("Username:");

jLabel3.setText("Password:");

jTextField1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jTextField1ActionPerformed(evt);

}

});

jPasswordField1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jPasswordField1ActionPerformed(evt);

}

});

jButton1.setText("Login");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

}

});

jButton2.setText("Reset");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(28, 28, 28)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(jLabel3))

.addGap(33, 33, 33)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)

.addComponent(jPasswordField1, 0, 0, Short.MAX_VALUE)

.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE)))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jButton1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2))))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(101, 101, 101)

.addComponent(jLabel1)))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel2))

.addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel3))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1)

.addComponent(jButton2)))

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

pack();

}// /editor-fold

private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

this.jTextField1.setText("");

this.jPasswordField1.setText("");

}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

String inputUsername = this.jTextField1.getText();

String inputPassword = String.valueOf(this.jPasswordField1.getPassword());

if(inputUsername.equals(username) inputPassword.equals(password)) {

JOptionPane.showMessageDialog(this, "Login success!");

} else {

JOptionPane.showMessageDialog(this, "Login failed!");

}

}

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

JFrame.setDefaultLookAndFeelDecorated(true);

Login login = new Login();

login.setVisible(true);

login.setLocationRelativeTo(null);

}

});

}

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JPanel jPanel1;

private javax.swing.JPasswordField jPasswordField1;

private javax.swing.JTextField jTextField1;

// End of variables declaration

}

在java里添加用戶注冊(cè)密碼校驗(yàn),和重復(fù)登錄的密碼確認(rèn),速求

代碼已寫(xiě)完,但是由于字?jǐn)?shù)問(wèn)題無(wú)法粘貼上來(lái)。把你郵箱給我,我給你發(fā)過(guò)去。

java 請(qǐng)教一下用戶名密碼校驗(yàn)的問(wèn)題

你這里沒(méi)有用文件也沒(méi)有用數(shù)據(jù)庫(kù),注冊(cè)的賬號(hào)只能用一次,當(dāng)程序關(guān)閉后,這個(gè)賬號(hào)的數(shù)據(jù)就沒(méi)有了。

建議使用文件或者數(shù)據(jù)庫(kù)保存注冊(cè)了的賬號(hào)和密碼。如果不是很清楚這兩個(gè)東西,建議再向后面學(xué)習(xí)。

JAVA 用戶密碼修改驗(yàn)證模塊,舊密碼,新密碼,確認(rèn)密碼

//Js中的驗(yàn)證

//檢查舊密碼

function?checkOldPassword(){

var?hasErr?=?false;

var?form?=?document.getElementById("form");

//檢查舊密碼

if(form.oldpass.value.length??1){

document.getElementById("errPwd").innerHTML?=?"請(qǐng)輸入您現(xiàn)在的密碼";

document.getElementById("errPwd").style.display?=?"inline-block";

hasErr?=?true;

}else{

document.getElementById("errPwd").style.display?=?"none";

}

return?hasErr;

}

//檢查新密碼

function?checkNewPassword(){

var?form?=?document.getElementById("form");

var?errNewPwdMsg?=?"";

var?hasErr?=?false;

if(form.password.value.length??1){

errNewPwdMsg?=?"請(qǐng)輸入新密碼";

}else?if?(?form.password.value?==?getSsn(form.username.value)?||?form.password.value?==?form.username.value){

errNewPwdMsg?=?"密碼和用戶名不能相同";

}else?if(?charAllSame(form.password.value)?){

errNewPwdMsg?=?"您的密碼過(guò)于簡(jiǎn)單";

}else?if(strlen(form.password.value)6?||?strlen(form.password.value)16?){

errNewPwdMsg?=?"正確的密碼長(zhǎng)度為6-16位";

}else?if(strlen2(form.password.value)){

errNewPwdMsg?=?"新密碼包含了非法字符";

}

else?if?(form.oldpass.value?==?form.password.value){

errNewPwdMsg?=?"新舊密碼不能相同";

}

if(errNewPwdMsg?!=?""){

document.getElementById("errNewPwd").innerHTML?=?errNewPwdMsg;

document.getElementById("errNewPwd").style.display?=?"inline-block";

hasErr?=?true;

}else{

document.getElementById("errNewPwd").style.display?=?"none";

}

return?hasErr;

}

//檢查新密碼確認(rèn)

function?checkNewPasswordConfirm(){

var?form?=?document.getElementById("form");

var?hasErr?=?false;

if(form.confirmPassword.value?!=?form.password.value?){

document.getElementById("errNewConfirmPwd").innerHTML?=?"您兩次輸入的新密碼不一致,請(qǐng)確認(rèn)";

document.getElementById("errNewConfirmPwd").style.display?=?"inline-block";

hasErr??=?true;

}else{

document.getElementById("errNewConfirmPwd").style.display?=?"none";

}

return?hasErr;

}

function?checkdata(form)?{

//檢查舊密碼

if(checkOldPassword()){

form.oldpass.focus();

return?false;

}

//檢查新密碼

if(checkNewPassword()){

form.password.focus();

return?false;

}

//檢查新密碼確認(rèn)

if(checkNewPasswordConfirm()){

form.confirmPassword.focus();

return?false;

}

JAVA 我要驗(yàn)證密碼是否一致怎么寫(xiě) return 啊

public boolean register_user(int pass){

boolean flag=true; //在此處定義變量

do {

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

String na = scanner.next();

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

String pas = scanner.next();

System.out.print("請(qǐng)?jiān)俅屋斎朊艽a");

String pa = scanner.next();

if (pa.equals(pas)){

System.out.println("注冊(cè)成功你的賬號(hào)為" + na + "你的密碼為" + pa);

} else {

System.out.println("注冊(cè)失敗你2才輸入的密碼不一致,請(qǐng)重新輸入");

flag=false;//如果失敗改變標(biāo)量的值

}

} while (!flag);

不需要return吧。。。

JAVA初學(xué):關(guān)于密碼驗(yàn)證的問(wèn)題?

import java.awt.*;

import java.awt.event.*;

public class TestPassword {

public static void main(String[]args) {

MyTestFrame mf = new MyTestFrame("密碼輸入");

}

}

class MyTestFrame extends Frame {

Button b = new Button("確認(rèn)");

TextField tf = new TextField(15);

public MyTestFrame(String str){

super(str);

tf.setEchoChar('*');

Panel p = new Panel();

p.setBackground(Color.BLACK);

b.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

String str = tf.getText();

// System.out.println(str);

if(str.length()8) {

System.out.println("輸入不能少于八位");

tf.setText("");

}

else {

if(str.matches("\\d*")) {

System.out.println("密碼強(qiáng)度低 ");

}

if(str.matches("[a-z0-9]*")){

System.out.println("密碼強(qiáng)度中 ");

}

if(str.matches("[a-zA-Z0-9]*")) {

System.out.println("密碼強(qiáng)度高");

}

}

}

});

this.setLayout(new BorderLayout());

p.add(tf);

this.add(b,BorderLayout.EAST);

this.add(p,BorderLayout.CENTER);

pack();

this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

}

}

可費(fèi)勁了 把課本又翻了一遍,正則表達(dá)式又復(fù)習(xí)了一下,gui也用上了


網(wǎng)站名稱:java代碼實(shí)現(xiàn)密碼驗(yàn)證 java輸入密碼驗(yàn)證
網(wǎng)頁(yè)鏈接:http://weahome.cn/article/hhjpoh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部