** 文本:文本框,密码框,文本域**
package GUI;
import javax.swing.*;
import java.awt.*;
// 文本:文本框,密码框,文本域
public class Test20 {
public static void main(String[] args) {
new JTextFieldDemo();
new JPasswordFieldDemo();
}
}
// 文本框 JTextField
class JTextFieldDemo extends JFrame {
public JTextFieldDemo() {
Container container = getContentPane();
JTextField 詹建海 = new JTextField("詹建海");
container.add(詹建海);
setVisible(true);
setTitle("文本框展示");
setSize(500,500);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
// 密码框 JPasswordField
class JPasswordFieldDemo extends JFrame {
public JPasswordFieldDemo() {
Container container = getContentPane();
// 设置密码框
JPasswordField jPasswordField = new JPasswordField();
jPasswordField.setEchoChar('*');
container.add(jPasswordField);
setVisible(true);
setTitle("密码框展示");
setSize(500,500);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
// 文本域 JTextArea ,一般配合 滚动面板使用
标签:container,文本框,密码,new,20,文本,public
From: https://www.cnblogs.com/zhanjianhai/p/17646626.html