Repainting JDialog

Hello,

I have a big problem. I want to repaint my JDialog and he don't wanna do this...

I need that for my Highscores. So you play and when you lost the game you can entre your name and the highscore will be added in the XML file, but my JDialog would not be repainted.

My code:

package bubblesstephaniemoelaert.visual;

import java.awt.Component;

import java.awt.FlowLayout;

import java.awt.GridLayout;

import java.util.Vector;

import javax.swing.JDialog;

import javax.swing.JLabel;

import javax.swing.JPanel;

import bubblesstephaniemoelaert.xml.XmlHighscores;

public class HighscoreManager {

protected XmlHighscores hs = XmlHighscores.lijst;

protected JDialog dial;

public static HighscoreManager instance;

public HighscoreManager(JDialog dial) {

this.dial = dial;

dial.getContentPane().setLayout(new GridLayout(10, 3));

loadScores();

instance = this;

}

public void loadScores() {

System.out.println("Loading scores ...");

Vector<Component> remove = new Vector<Component>();

for (Component c : dial.getContentPane().getComponents()) {

if (c instanceof JLabel)

remove.add(c);

}

for (Component c : remove) {

dial.getContentPane().remove(c);

}

for (int i = 0; i < 10; i++) {

try {

JLabel jl = new JLabel((i + 1) + ". " + hs.getScores(i)[0]);

dial.add(jl);

for (int j = 1; j < 3; j++) {

jl = new JLabel(hs.getScores(i)[j]);

System.out.print(hs.getScores(i)[j] + ".. ");

dial.add(jl);

}

System.out.println("");

} catch (ArrayIndexOutOfBoundsException e) {

JPanel jp = new JPanel();

jp.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));

JLabel jl = new JLabel((i + 1) + ". ");

JLabel jl2 = new JLabel();

VertalingsManager.voegToe(jl2, "<geen>");

jp.add(jl);

jp.add(jl2);

dial.add(jp);

for (int j = 1; j < 3; j++) {

jl = new JLabel("*");

dial.add(jl);

}

}

}

System.out.println("Total: " + dial.getContentPane().getComponentCount());

dial.repaint();

}

}

[2249 byte] By [darkstar001a] at [2007-11-27 5:16:23]
# 1
dial.pack()dial.revalidate(); // or dial.invalidate(); dial.validate();
bsampieria at 2007-7-12 10:38:59 > top of Java-index,Java Essentials,Java Programming...