GUI之绘制简单文本框
package day15; import javax.swing.*; import java.awt.*; public class TextField extends JFrame { public TextField() { Container container = this.getContentPane(); JTextField textField1 = new JTextField("xiao"); JTextField textField2 = new JTextField("ming", 30); container.add(textField1, BorderLayout.NORTH); container.add(textField2, BorderLayout.SOUTH); this.setVisible(true); this.setSize(200, 200); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } public static void main(String[] args) { new TextField(); } }
执行结果:
欢迎批评指正,提出问题,谢谢!