Java GridLayout problem.

Caporegime
Joined
12 Mar 2004
Posts
29,962
Location
England
When I try this,

Code:
keys[i][y] = new JPanel();

It says that an array was expected but gridlayout found, the thing is though I have done exactly this before in other programs but it worked fine. :confused: I thought you can access the elements of a gridlayout just like you can with an array?
 
I thought you can access the elements of a gridlayout just like you can with an array?

Nope, elements are added sequentially to fill in the grid.

A 2x2 grid layout would be declared as follows:
Code:
container.setLayout(new GridLayout(2,2));

Elements are added by:
Code:
container.add([B]<element>[/B]);

Where <element> is a component.
 
Last edited:
Back
Top Bottom