I wish to generate a chess board(8 X 8) using an object array of JButton .However as a basic step towards it the program below should place ten JButtons one below the other(10 X 1). But the in the output it shows only two buttons(2 X1).
import javax.swing.*;
import java.awt.*;
public class Abcd extends JFrame
{
JButton b[]=new JButton[10];
Abcd()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(null);
setSize(500, 500);
int x=0,y=0;
for(int i=0;i<b.length;i++)
{
b[i] = new JButton();
}
for(int i=0;i<b.length;i++)
{
b[i].setBounds(x,y,50,50);
b[i].setVisible(true);
add(b[i]);
y=+50;
}
setVisible(true);
}
public static void main(String args[])
{
new Abcd();
}
}