java jpanel not functioning
I'm trying to make a 4x5 Grid within a JPanel that is on a BORDERLAYOUT in EAST... soo here is pic:
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 开发者_JS百科= 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?
it's add(invOne, BorderLayout.CENTER);
. You should use constants from BorderLayout class instead of strings.
精彩评论