package GUI;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.io.*;
import java.util.Scanner;
public class DemoJTextArea_JScrollPane_JTextFiled_JPasswordFiled {
public static void main(String[] args) throws IOException {
//框架
JFrame frm = new JFrame("文本编辑功能窗口");
frm.setLocation(200, 150);//设置窗口的位置
frm.setSize(500, 500);//设置窗口的大小
frm.setVisible(true);
frm.setLayout(null);
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setResizable(false);
//面板
JPanel jpl = new JPanel();
jpl.setSize(450, 450);
jpl.setLocation(2, 3);
jpl.setBorder(new TitledBorder("JPanel面板区"));
frm.add(jpl);
//密码输入区
Scanner reader = new Scanner(System.in);
String password = reader.next();
JPasswordField jpf = new JPasswordField(password, 30);
char[] chars = jpf.getPassword();
jpf.setBounds(20, 10, 140, 20);//设置密码文本行位置和大小 左上长宽
// frm.add(jpf);
jpl.add(jpf);
//提示密码输入的不可编辑文本区
JTextField jtf = new JTextField("请在上面的密码区输入今日口令", 30);
jtf.setEditable(false);
jtf.setBounds(20, 40, 140, 20);
// frm.add(jtf);
jpl.add(jtf);
//不可编辑的显示口令区域
JTextField jtf2 = new JTextField(new String(chars), 30);
jtf2.setEditable(false);
jtf2.setBounds(20, 70, 140, 20);
// frm.add(jtf2);
jpl.add(jtf2);
//可以输入文字的文本区域
JTextArea jta = new JTextArea("此处可以输入备忘", 10, 30);
jta.setEditable(true);
//可以输入文字的文本区域的滚动窗格
JScrollPane jsp = new JScrollPane(jta);
jsp.setBounds(20, 100, 160, 100);
// frm.add(jsp);
jpl.add(jsp);
}
}
