其他分享
首页 > 其他分享> > GUI之绘制简单文本框

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

    }

}

执行结果:

标签:textField2,container,GUI,文本框,new,TextField,绘制,public,JTextField
来源: https://www.cnblogs.com/xxeleanor/p/15116578.html