views:

31

answers:

1

I'm trying to make a 4x5 Grid within a JPanel that is on a BORDERLAYOUT in EAST... soo here is pic:

alt text

Here is the code:

setLayout( new BorderLayout() );

JPanel invOne = new JPanel(newGridLayout(4,5));

JPanel game = new JPanel();

 add("Center",invOne);

 add("East", game);

 add("South", c); 

for (int i = 0, j = 20; i < 20; i = i+1, j = j-1) {

invOne.add(new JButton("SLOT " + j));

}

As you can see the invinventory slots are OVERLAPPING the game panel which should NOT happen because the game panel is in the CENTER of the BorderLayout and the Inventory panel (invOne) is on the EAST of the BorderLayout so I don't know why it's overlapping...

help?

A: 

it's add(invOne, BorderLayout.CENTER);. You should use constants from BorderLayout class instead of strings.

tulskiy
-1, This doesn't solve the problem. The OP was given a link to the Swing tutorial which shows the proper way to do this in a previous posting. He was also given a reminder to again read the tutorial.
camickr
@camickr: It did fix the problem he asked about, you can see it in his next post :) BTW, I tried looking for the post where you gave him a link to the tutorial before posting, but didn't find it.
tulskiy