利用流式布局对按钮进行排版

package StudyGUI;

import java.awt.*;

public class StudyButton {
    public static void main(String[] args) {
        Frame frame = new Frame("流式布局");
         Button  one = new Button("按钮1");
         Button two = new Button("按钮2");
         Button three = new Button("按钮3");
         Button four = new Button("按钮4");
          //设置为流失布局
        //frame.setLayout(new FlowLayout());
        //定义布局在左边
        //定义流式布局setLayout
        frame.setLayout(new FlowLayout(FlowLayout.LEFT));
        frame.setSize(600,600);
        //把按钮添加上去
        frame.add(one);
        frame.add(two);
        frame.add(three);
        frame.add(four);
        frame.setVisible(true);
    }
}

posted @ 2022-07-31 17:11  鹅城小铁匠  阅读(53)  评论(0)    收藏  举报
Fork me on GitHub