learning java AWT BoxLayout布局管理器
作者:互联网
import javax.swing.*; import java.awt.*; public class BoxSpaceTest { private Frame f = new Frame("test"); private Box horizontal = Box.createHorizontalBox(); private Box vertical = Box.createVerticalBox(); public void init(){ horizontal.add(new Button("button01")); horizontal.add(Box.createHorizontalGlue()); horizontal.add(new Button("button02")); horizontal.add(Box.createHorizontalStrut(10)); horizontal.add(new Button("button03")); vertical.add(new Button("vbutton01")); vertical.add(Box.createVerticalBox()); vertical.add(new Button("vbutton02")); vertical.add(Box.createVerticalStrut(10)); vertical.add(new Button("vbutton03")); f.add(horizontal, BorderLayout.NORTH); f.add(vertical); f.pack(); f.setVisible(true); } public static void main(String[] args) { new BoxSpaceTest().init(); } }
output:
标签:Box,管理器,vertical,Button,AWT,add,learning,new,horizontal 来源: https://www.cnblogs.com/lianghong881018/p/11270466.html