Salut,
ich wollte in meiner Anwendung zur Anzeige des aktuellen Status eine ProgressBar anzeigen. Bloß wird diese leider nicht aktualisiert. Hier eine Beispielklasse:
Wie erzwinge ich denn das Neuzeichnen?
Stefan
ich wollte in meiner Anwendung zur Anzeige des aktuellen Status eine ProgressBar anzeigen. Bloß wird diese leider nicht aktualisiert. Hier eine Beispielklasse:
Code:
public class ProgressGUI extends JFrame implements ActionListener {
JProgressBar progressBar;
JButton startButton;
public ProgressGUI()
{
this.setSize(new Dimension(400, 300));
FlowLayout fl = new FlowLayout();
this.setLayout(fl);
this.progressBar = new JProgressBar();
this.add(this.progressBar);
this.startButton = new JButton("Start");
this.startButton.addActionListener(this);
this.add(this.startButton);
}
@Override
public void actionPerformed(ActionEvent arg0) {
for (int i = 0; i < 100; i++) {
this.progressBar.setValue(i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.progressBar.invalidate();
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ProgressGUI pg = new ProgressGUI();
pg.setVisible(true);
}
Stefan