首页 > 编程语言 > 详细

Java图形界面(3)

时间:2021-05-24 15:37:30      阅读:9      评论:0      收藏:0      [点我收藏+]
 1 package t1;
 2 import javax.swing.*;
 3 public class Test5 extends JFrame {
 4     JTextField jtf=new JTextField("该文本框不可编辑",30);
 5     static JPasswordField jpf=new JPasswordField("太空人3号",30);
 6     public Test5(String str) {
 7         super(str);
 8         jtf.setBounds(20,40,140,20);
 9         jtf.setEditable(false);
10         add(jtf);
11     }
12     public static void main(String[] args) {
13 
14         Test5 frm=new Test5("文本编辑窗口");
15         JTextArea jta=new JTextArea("您好",10,30);
16         JScrollPane jsp=new JScrollPane(jta);
17         frm.setLocation(200, 150);
18         frm.setSize(240, 220);
19         frm.setLayout(null);
20         jsp.setBounds(20, 70, 160, 100);
21         jpf.setBounds(20, 10, 140, 20);
22         jpf.setEchoChar(‘*‘);
23         frm.add(jpf);
24         frm.add(jsp);
25         char[] password=jpf.getPassword();
26         String str=new String(password);
27         System.out.println("今天口令是: "+password+"  转换成文本后是: "+str);
28         frm.setVisible(true);
29         frm.setResizable(false);
30         frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
31         
32     }
33 
34 }

 

Java图形界面(3)

原文:https://www.cnblogs.com/ljydbk/p/14804064.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!