GUI Swing 3.7 文本框
作者:互联网
3.7 文本框
-
文本框
public class TestTextField extends JFrame { public TestTextField() { Container contentPane = getContentPane(); //文本框 JTextField jTextField = new JTextField("你好,么么叽"); contentPane.add(jTextField); setVisible(true); setBounds(200,200,200,100); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { new TestTextField(); } }
-
密码框
public class TestPswdText extends JFrame { public TestPswdText(){ Container contentPane = getContentPane(); //密码框 JPasswordField jPasswordField = new JPasswordField(); //也可以设置密码类型 jPasswordField.setEchoChar('*'); contentPane.add(jPasswordField); setVisible(true); setBounds(200,200,400,200); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { new TestPswdText(); } }
-
文本域
public class TestTextAre extends JFrame { public TestTextAre(){ Container contentPane = getContentPane(); //文本域 JTextArea jTextArea = new JTextArea("么么叽",30,50); contentPane.add(jTextArea); setVisible(true); setBounds(200,200,400,200); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { new TestTextAre(); } }
标签:200,Container,GUI,文本框,3.7,contentPane,new,public 来源: https://www.cnblogs.com/NeverGGp/p/16023065.html