Java Code
import java.awt.*;
import javax.swing.*;
public class GridLayoutEx extends JApplet
{
JButton b1, b2, b3, b4, b5;
JPanel pane = new JPanel();
public void init( )
{
setLayout( new GridLayout(3,2) );
b1 = new JButton( "First" );
b2 = new JButton( "Two" );
b3 = new JButton( "Three" );
b4 = new JButton( "Four" );
b5 = new JButton( "Five" );
add( b1 );
add( b2 );
add( b3 );
add( b4 );
add( b5 );
pane.setLayout( new BorderLayout() );
JButton a = new JButton( "go" );
JButton b = new JButton( "there" );
pane.add( a, BorderLayout.NORTH );
pane.add( b, BorderLayout.CENTER );
add( pane );
}
}
Back to Code Examples
©2006-
by E.S.Boese. All Rights Reserved