//file: Grid.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Grid extends JPanel {
public Grid( ) {
setLayout(new GridLayout(3, 2));
add(new JButton("One"));
add(new JButton("Two"));
add(new JButton("Three"));
add(new JButton("Four"));
add(new JButton("Five"));
}
public static void main(String[] args) {
JFrame f = new JFrame("Grid");
f.addWindowListener(new WindowAdapter( ) {
public void windowClosing(WindowEvent e) { System.exit(0); }
});
f.setSize(200, 200);
f.setLocation(200, 200);
f.setContentPane(new Grid( ));
f.setVisible(true);
}
}
|