Topic: 在AWT中,password在输入的时候如何显示*号

  Print this page

1.在AWT中,password在输入的时候如何显示*号 Copy to clipboard
Posted by: RingofAngel
Posted on: 2005-06-27 18:45

抱歉,我提了一个很菜的问题。
我找了一下api,但是没有找到awt中这样的组件(为什么swing有呢?)
我想到的是用时间相应,记录输入的字符数,然后在TextField中显示同样多的*。

可是觉得太麻烦了,不合适。

各位高手指点一下好么?

2.Re:在AWT中,password在输入的时候如何显示*号 [Re: RingofAngel] Copy to clipboard
Posted by: why
Posted on: 2005-06-27 21:12

Google for it...

http://java.sun.com/developer/technicalArticles/Security/pwordmask/

http://www.jguru.com/faq/view.jsp?EID=115225
import java.awt.*;
import java.awt.event.*;

public class PasswordDemo extends Frame {
public PasswordDemo() {
TextField password = new TextField(10);
password.setEchoChar('*');
add(password);
}
public static void main(String[] argv) {
final PasswordDemo f = new PasswordDemo();
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}

3.Re:在AWT中,password在输入的时候如何显示*号 [Re: RingofAngel] Copy to clipboard
Posted by: snowbird2005
Posted on: 2005-06-27 21:13

setEchoChar
public void setEchoChar(char c)
Sets the echo character for this text field.
An echo character is useful for text fields where user input should not be echoed to the screen, as in the case of a text field for entering a password. Setting echoChar = 0 allows user input to be echoed to the screen again.

Parameters:
c - the echo character for this text field.

4.Re:在AWT中,password在输入的时候如何显示*号 [Re: RingofAngel] Copy to clipboard
Posted by: RingofAngel
Posted on: 2005-06-28 08:16

Sorry ,I can`t use Google well.
And thanks for your help.

5.Re:在AWT中,password在输入的时候如何显示*号 [Re: RingofAngel] Copy to clipboard
Posted by: why
Posted on: 2005-06-28 08:46

RingofAngel wrote:
Sorry ,I can`t use Google well.

You should be able to find this kind of information with your favourite search engine.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923