Hi
Ich hab folgendes Problem:
Ich möchte gerne aus meinem JPanel - GridBag Elemente wieder löschen und diese durch andere Elemente ersetzen.
Danke im Voraus!
Ich hab folgendes Problem:
Ich möchte gerne aus meinem JPanel - GridBag Elemente wieder löschen und diese durch andere Elemente ersetzen.
Code:
private JPanel createPlField()
{
JPanel wind = new JPanel();
wind.setForeground(Color.black); //funktioniert leider auch nicht...
GridBagLayout gbl = new GridBagLayout();
wind.setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
img = new BitmapComponent("ar1.png");
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.NORTHEAST;
wind.add(img, gbc);
int zeilen = 1;
for (int k = 1; k < 6; k++)
{
img = new BitmapComponent("images\\elements\\none.jpg");
gbc.gridx = k;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.NORTHEAST;
wind.add(img, gbc);
}
for (int i = 1; i < 8; i++) //Zeile(n) -> 7
{
for (int j = 0; j < 6; j++) //Spalte(n)
{
img = new BitmapComponent("images\\feld\\player1\\feld1_"+zeilen+".jpg");
gbc.gridx = j;
gbc.gridy = i;
gbc.anchor = GridBagConstraints.NORTHEAST;
list.add(gbc);
arr.add(img);
GridBagConstraints temp = new GridBagConstraints();
temp = (GridBagConstraints) list.get(zeilen-1);
wind.add(img, temp);
zeilen++;
}}}