Java Reference
In-Depth Information
LISTING 7.22
//********************************************************************
// GridPanel.java Author: Lewis/Loftus
//
// Represents the panel in the LayoutDemo program that demonstrates
// the grid layout manager.
//********************************************************************
import java.awt.*;
import javax.swing.*;
public class GridPanel extends JPanel
{
//-----------------------------------------------------------------
// Sets up this panel with some buttons to show how grid
// layout affects their position, shape, and size.
//-----------------------------------------------------------------
public GridPanel()
{
setLayout ( new GridLayout (2, 3));
setBackground (Color.green);
JButton b1 = new JButton ("BUTTON 1");
JButton b2 = new JButton ("BUTTON 2");
JButton b3 = new JButton ("BUTTON 3");
JButton b4 = new JButton ("BUTTON 4");
JButton b5 = new JButton ("BUTTON 5");
add (b1);
add (b2);
add (b3);
add (b4);
add (b5);
}
}
Search WWH ::




Custom Search