|
java.awt paketi
|
Yatay ve düşey kenarlar ile container istenen sayıda dikdörtgenlere ayrılır. Her dikdörtgen içine bir düğme konuşlanır.
Aşağıdaki resim bir GridLayout örneğidir.
Bunu yaratan program aşağıdadır :
// GridLayout Manager
import java.awt.*;
public class GridLayoutExample extends Frame {
public GridLayoutExample(String title, int rows, int columns) {
super(title);
setLayout(new GridLayout(rows, columns));
for(int i = 0; i < rows; i++)
for(int j = 0; j < columns; j++)
add(new Button(Integer.toString(i)+"," + Integer.toString(j)));
}
public static void main(String[] args) {
int rows = (args.length == 0) ? Integer.parseInt(args[0]) : 10;
int columns = (args.length == 2) ? Integer.parseInt(args[1]) : 10;
GridLayoutExample gle = new GridLayoutExample("GridLayoutExample", rows, columns);
gle.setSize(300, 300);
gle.show();
}
}