I am making code for the game connect four. I create a JPanel with a 2 dimensional array of JButtons and use pack() to put it into the JFrame. When i set the size of the JFrame in the main method, the JPanel remains small. How do I get this to work? thanks
here's the constructor
public ConnectFour(int boardsize, int winlength){
super();
boardSize = boardsize;
winLength = winlength;
Container c = getContentPane();
JPanel board = new JPanel(new GridLayout(boardSize, boardSize));
button = new JButton[boardSize][boardSize];
//loop creates a 2 dimensional JButton array
for(int i =0; i
{
for(int j =0; j
{
button[j][i] = new JButton();
board.add(button[j][i]);
button[j][i].addActionListener(this);
}
}
c.add(board);
pack();
-------------------------
this.setVisible(true);
this.setSize(700,700);
c.setSize(700,700);
2006-11-12
14:35:22
·
1 answers
·
asked by
snoboarder2k6
3
in
Computers & Internet
➔ Programming & Design