[Gelöst] Wie bekomme ich Gridlayout, um die JPANELS -Einschale zu respektieren?Java

Java-Forum
Anonymous
 [Gelöst] Wie bekomme ich Gridlayout, um die JPANELS -Einschale zu respektieren?

Post by Anonymous »

Ich versuche, einen Gridlayout zu verwenden, um eine Gruppe von JPanels zu organisieren. Die Polsterung wirkt sich nur auf die Oberseite und links aus. (Siehe Bild unten) < /p>
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);
}

}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post