其他分享
首页 > 其他分享> > AWT_按钮组件

AWT_按钮组件

作者:互联网

AWT_按钮组件

package Demo01;

import java.awt.*;

public class TestFlowLayout {
    public static void main(String[] args) {
        Frame frame = new Frame();

        //组件-按钮组件
        Button button1 = new Button("button1");
        Button button2 = new Button("button2");
        Button button3 = new Button("button3");

        //设置为流式布局
        //frame.setLayout(new FlowLayout());//默认居中
        //frame.setLayout(new FlowLayout(FlowLayout.LEFT));
        frame.setLayout(new FlowLayout(FlowLayout.RIGHT));

        frame.setSize(400,400);
        //把按钮添加上去
        frame.add(button1);
        frame.add(button2);
        frame.add(button3);

        frame.setVisible(true);
    }
}

标签:frame,AWT,FlowLayout,按钮,组件,new,Button
来源: https://blog.csdn.net/weixin_50569789/article/details/117871558