gui文本框,密码框,文本域补充
package gui.lesson01.lesson04;
import javax.swing.*;
import java.awt.*;
public class TextCombobox02 extends JFrame {
public TextCombobox02() {
Container container = this.getContentPane();
container.setLayout(new FlowLayout());
JPasswordField jPasswordField = new JPasswordField(20); //尽量放在面板上,位置好把握,创建密码框
JTextField jTextField = new JTextField("world"); //创建文本框。文本域是JTextArea
container.add(jPasswordField); //把密码框和文本框放到容器上
container.add(jTextField);
this.setVisible(true);
this.setBounds(100,100,300,400);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new TextCombobox02();
}
}