美文网首页
2021-09-22 GUI(Frame)

2021-09-22 GUI(Frame)

作者: Denholm | 来源:发表于2021-10-20 20:31 被阅读0次
fede2e4a3c02443092eaee1446340056.jpg
import java.awt.*;

/**
 * 创建图形化界面
 * 1.创建Frame窗体
 * 2.对窗体进行基本设置,如大小、位置、布局
 * 3.定义组件
 * 4.将组件通过窗体的add方法添加到窗体中
 * 5.让窗体显示,通过setVisible(true)
 */
public class AwtDemo {

    public static void main(String[] args) {
        Frame f = new Frame("my awt");
        f.setSize(400, 500);
        f.setLocation(300, 300);
        f.setLayout(new FlowLayout());

        Button b = new Button("我是一个按钮");

        f.add(b);
        f.setVisible(true);
    }

}

相关文章

网友评论

      本文标题:2021-09-22 GUI(Frame)

      本文链接:https://www.haomeiwen.com/subject/ekiggltx.html