Codeergebnis < /p>
Code: Select all
public class InventoryView extends JPanel
{
private InventoryBox[] boxes;
public InventoryView()
{
this.setLayout(new GridLayout(4, 7, 2, 2));
//grid is set for 28, and I'm adding 32
boxes = new InventoryBox[32];
for(int i = 0; i < boxes.length; i++) {
boxes[i] = new InventoryBox();
//Creates a new jpanel and makes it blue
add(boxes[i]);
}
}
@Override
public Insets getInsets()
{
return new Insets(1, 1, 1, 1);
}
}