learning java AWT 绝对定位

import javax.swing.*;
import java.awt.*;

public class NullLayoutTest {
    Frame f = new Frame("测试窗口");
    Button b1 = new Button("BUTTON01");
    Button b2 = new Button("BUTTON02");
    public void init(){
        f.setLayout(null);

        b1.setBounds(20,30, 90,28);
        b2.setBounds(50,45,120,35);
        f.add(b1);
        f.add(b2);

        f.setBounds(50,50,200,100);
        //f.pack();
        f.setVisible(true);
    }


    public static void main(String[] args) {
        new NullLayoutTest().init();
    }
}

output:

posted @ 2019-07-30 15:17  嵌入式实操  阅读(279)  评论(0编辑  收藏  举报