/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ import java.awt.GridLayout; import javax.swing.JApplet; import javax.swing.JButton; import javax.swing.JFrame; public class GridLayoutApplet extends JApplet { JFrame f; public void init() { f = new MyGridFrame(); f.setVisible(true); } } class MyGridFrame extends JFrame { public MyGridFrame() { setTitle("Grid Layout Demo"); setSize(300, 300); setLayout(new GridLayout(2,4)); add(new JButton("yellow")); add(new JButton("magenta")); add(new JButton("red")); add(new JButton("green")); add(new JButton("blue")); add(new JButton("black")); add(new JButton("white")); pack(); } }