
正文
java密码框代码论文 java密码框显示文字
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
JAVA swing 中 密码框显示其他符号怎么显示? 我知道可以使用setEchoChar(' ')来实现 但完整代码怎么写
passwordField = new JPasswordField();
passwordField.setForeground(Color.BLACK); //设置输入java密码框代码论文的字的颜色
passwordField.setEchoChar('*');
passwordField.setOpaque(false); //透明框
passwordField.setBounds(128, 189, 104, 21); //(空白框在窗体中x轴的位置java密码框代码论文,空白框在窗体中y轴的位置java密码框代码论文,空白框的宽java密码框代码论文,空白框的高)
contentPane.add(passwordField); //加入设置面板中
相关问答
Q1: java 中密码用 * 代替怎么写代码
密码文本框用JPasswordField,输入内容自动为*号,当然可以转换成●或其他
Q2: JAVA .编写GUI程序,要求:用户在密码框中输入数据,将输入的字符显示在另一个文本框中。
这个和java密码框代码论文你想要java密码框代码论文的差不多了
import java.awt.FlowLayout;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class Test extends JFrame implements ActionListener {// 继承窗体JFrame,声明借口ActionListener。
/**
*
*/
private static final long serialVersionUID = 1L;
JLabel input = new JLabel(" 请输入密码:");// 实例化一个标签对象。
TextField password = new TextField(13);// 实例化一个文本框对象。
JButton submit = new JButton("提交");// 实例化一个按钮对象。
JButton reset = new JButton("重置");
JLabel output = new JLabel("你输入java密码框代码论文的密码是:");
JTextField show = new JTextField(10);
Test() {// 构造函数
super("0.0");// 窗体名字。
this.setLayout(new FlowLayout());// 窗体布局。(流式布局)
submit.addActionListener(this);// 给按钮添加事件监听。(给按钮注册监听器)
reset.addActionListener(this);
this.add(input);// 将各组件添加在窗体上。
password.setEchoChar('*');// 设置掩码。
this.add(password);
this.add(output);
this.add(show);
this.add(submit);
this.add(reset);
this.setSize(245, 200);// 设置窗体大小。
this.setVisible(true);// 设置窗体可见。
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置窗体可关闭java密码框代码论文,程序可正常退出。
}
public static void main(String[] args) {
new Test();// 实例化类
}
public void actionPerformed(ActionEvent e) {
String str = password.getText();// 将password文本框中的字符取出存在str中。
JButton jb = (JButton) e.getSource();// 获得按钮事件的事件源
if (jb == submit) {// 点击了submit按钮
show.setText(str);// 设置show文本框中的内容为str中的内容
}
if (jb == reset) {// 点击了reset按钮
password.setText(null);// 文本框清空
show.setText(null);
}
}
}
java密码框代码论文的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java密码框显示文字、java密码框代码论文的信息别忘了在本站进行查找喔。







