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();

    }

}

执行结果:

posted @ 2021-08-08 22:46  Eleanor123  阅读(91)  评论(0编辑  收藏  举报