bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

java設(shè)置密碼框代碼 java如何設(shè)置密碼輸入框

怎么用JAVA做QQ登陸界面的密碼框

import?java.awt.*;

創(chuàng)新互聯(lián)公司專(zhuān)注于慈溪企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),商城網(wǎng)站定制開(kāi)發(fā)。慈溪網(wǎng)站建設(shè)公司,為慈溪等地區(qū)提供建站服務(wù)。全流程按需設(shè)計(jì)網(wǎng)站,專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)公司專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)

import?java.awt.event.*;

import?javax.swing.*;

public?class?QQLogin?extends?JFrame?{

JTextField?jtf,jtf1;

public?QQLogin()?{

jtf?=?new?JTextField(12);

jtf.setText("請(qǐng)輸入");

jtf.setForeground(Color.GRAY);//?設(shè)置顏色

JPanel?jp?=?new?JPanel();

jp.add(jtf);

jtf1?=?new?JTextField(12);

JPanel?jp1?=?new?JPanel();

jp1.add(jtf1);

this.add(jp1,?BorderLayout.NORTH);

this.add(jp,BorderLayout.SOUTH);

this.setTitle("密碼輸入提示");

this.setBounds(300,?200,?220,?160);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

//jp1.getComponents()[0].setBackground(Color.RED);

//jp1上可能添加了很多組件,于是可以使用getComponents()返回一個(gè)組件數(shù)組。

//[0]表示選取該組件數(shù)組的第一個(gè)組件

//setBackground(Color.RED)?表示把該組件變成紅色的背景顏色

jtf.addFocusListener(new?FocusListener()?{

@Override

public?void?focusLost(FocusEvent?e)?{//?失去焦點(diǎn)的時(shí)候

//?如果內(nèi)容為空,設(shè)置文本

if?(jtf.getText().trim().equals(""))?{

jtf.setText("請(qǐng)輸入");

}

}

@Override

public?void?focusGained(FocusEvent?e)?{//?得到焦點(diǎn)的時(shí)候

if?(jtf.getText().trim().equals("請(qǐng)輸入"))?{

jtf.setText("");//?讓文本為空白

}

}

});

}

public?static?void?main(String[]?args)?{

new?QQLogin();

}

}

代碼上已經(jīng)回答了你的2個(gè)問(wèn)題

java中密碼框的長(zhǎng)度怎么設(shè)置,比如銀行管理系統(tǒng)的密碼限定為6位,要原創(chuàng)代碼,最好是一個(gè)內(nèi)部類(lèi)

passwordField.addKeyListener(new KeyListener() {//創(chuàng)建一個(gè)監(jiān)聽(tīng)器

@Override

public void keyTyped(KeyEvent e) {//按下的監(jiān)聽(tīng)器

String passString =new String(passwordField.getPassword());//取回密碼框的內(nèi)容

if (passString.length()==5) {//判斷長(zhǎng)度

e.consume();//輸入無(wú)效

}

}

@Override

public void keyReleased(KeyEvent e) {

// TODO Auto-generated method stub

}

@Override

public void keyPressed(KeyEvent e) {

// TODO Auto-generated method stub

}

});

JAVA swing 中 密碼框顯示其他符號(hào)怎么顯示? 我知道可以使用setEchoChar(' ')來(lái)實(shí)現(xiàn) 但完整代碼怎么寫(xiě)

完整代碼如下:

import javax.swing.JFrame;

import javax.swing.JTextField;

import javax.swing.JPasswordField;

import javax.swing.JLabel;

import javax.swing.JButton;

import java.awt.Container;

import java.awt.Insets;

import java.awt.Dimension;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

import java.awt.event.WindowEvent;

import java.awt.event.WindowAdapter;public class FieldDemo extends JFrame implements ActionListener {

JTextField nameField;

JPasswordField passField; public static void main(String arg[]) {

new FieldDemo();

} public FieldDemo() {

int height;

int width;

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

setLocation(250, 150);

Container pane = getContentPane();

pane.setLayout(null);

Insets insets = pane.getInsets(); JLabel nameLabel = new JLabel("User name");

Dimension labelDim = nameLabel.getPreferredSize();

int x1 = insets.left + 20;

int y1 = insets.top + 20;

nameLabel.setBounds(x1, y1, labelDim.width, labelDim.height);

nameLabel.setHorizontalTextPosition(JLabel.RIGHT);

pane.add(nameLabel); JLabel passLabel = new JLabel("Password");

int x2 = x1;

int y2 = y1 + labelDim.height + 20;

passLabel.setBounds(x2, y2, labelDim.width, labelDim.height);

passLabel.setHorizontalTextPosition(JLabel.RIGHT);

pane.add(passLabel); nameField = new JTextField(32);

x1 += labelDim.width;

Dimension textDim = nameField.getPreferredSize();

nameField.setBounds(x1, y1, textDim.width, textDim.height);

pane.add(nameField); passField = new JPasswordField(32);// 密碼框?qū)S茫瑳](méi)有明文回顯

x2 += labelDim.width;

passField.setBounds(x2, y2, textDim.width, textDim.height);

pane.add(passField); width = x1 + textDim.width + 20 + insets.left; JButton button = new JButton("Login");

Dimension buttonDim = button.getPreferredSize();

int x3 = (width - buttonDim.width) / 2;

int y3 = y2 + labelDim.height + 20;

button.setBounds(x3, y3, buttonDim.width, buttonDim.height);

button.addActionListener(this);

pane.add(button); height = y3 + buttonDim.height + 40 + insets.bottom; setSize(width, height);

setVisible(true);

} public void actionPerformed(ActionEvent e) {

System.out.println(nameField.getText());

char password[] = passField.getPassword();

System.out.println(password);

System.exit(0);

}

}

用java做的界面點(diǎn)確定彈出輸入密碼框怎么寫(xiě)啊要求6位數(shù)字

JTextField jtf=new JTextField();

String str=jtf.getText().trim();//密碼字符串

JOptionPane.showConfirmDialo(this,jtf ,"輸入密碼",JOptionPane.OK_CANCEL_OPTION );

if(str.length!=6){

JOptionPane.showMessageDialog(this,"請(qǐng)輸入6位密碼");

}

//直接打的,可能有錯(cuò)誤

java 在網(wǎng)頁(yè)上添加用戶(hù)名和密碼輸入框,以及登錄按鈕(不要求實(shí)現(xiàn)登錄功能),

!DOCTYPE?html

html

head

title登錄/title

/head

body

form?onsubmit="return?check()"

label用戶(hù)名/labelinput?id="username"?type="text"?name="username"

label密碼/labelinput?id="password"?type="password"?name="password"

input?type="submit"?value="登錄"

/form

script?type="text/javascript"

function?check(){

var?username?=?document.getElementById("username").value;

var?password?=?document.getElementById("password").value;

if(!username){

alert("用戶(hù)名不能為空!");

return?false;

}

if(!password){

alert("密碼不能為空!");

return?false;

}

return?true

}

/script

/body

/html

當(dāng)前文章:java設(shè)置密碼框代碼 java如何設(shè)置密碼輸入框
文章URL:http://vcdvsql.cn/article14/hhpgde.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、網(wǎng)站內(nèi)鏈、靜態(tài)網(wǎng)站關(guān)鍵詞優(yōu)化網(wǎng)站制作、動(dòng)態(tài)網(wǎng)站

廣告

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

成都seo排名網(wǎng)站優(yōu)化