import java.awt.*; public class TestBorderLayout { public static void main(String[] args) { Frame f = new Frame("Border Layout"); Button bn = new Button("BN"); Button bs = new Button("BS"); Button bw = new Button("BW"); Button be = new Button("BE"); Button bc = new Button("BC"); f.add(bn, BorderLayout.NORTH); f.add(bs, BorderLayout.SOUTH); f.add(bw, BorderLayout.WEST); f.add(be, BorderLayout.EAST); f.add(bc, BorderLayout.CENTER); f.setSize(600,300); f.setVisible(true); } }import java.awt.*; public class TestGridLayout { public static void main(String[] args) { Frame f = new Frame("GridLayout"); for(int i = 0; i < 6; i++) { f.add(new Button("b" + i)); } f.setLayout(new GridLayout(3, 2)); f.pack(); f.setVisible(true); } }
posted on 2012-05-06 16:13 spring学习笔记 阅读(407) 评论(0) 编辑 收藏 举报