Y
Yoshi
Hello,
I want to start a thread/animation after a mouse click.
My problem is that the corresponding panel isn't repainted
by the thread - as soon as the thread has ended, the
repaint works... Here's a little code snippet:
________________________________________
public void mousePressed(MouseEvent e) {
counter = 0;
new Thread() {
public void run() {
while(counter < 20) {
counter++;
repaint();
try { Thread.sleep(100); } catch(Exception e) {}
}
}
}.start();
}
________________________________________
I tried to put the thread in another class, I tried different
versions of Runnable & Thread, I tried to find an easy
solution in some tutorial, but nothing is working. I'd be
very happy to get a solution for this problem...
Thanks very much!
Yoshi Okamoto
I want to start a thread/animation after a mouse click.
My problem is that the corresponding panel isn't repainted
by the thread - as soon as the thread has ended, the
repaint works... Here's a little code snippet:
________________________________________
public void mousePressed(MouseEvent e) {
counter = 0;
new Thread() {
public void run() {
while(counter < 20) {
counter++;
repaint();
try { Thread.sleep(100); } catch(Exception e) {}
}
}
}.start();
}
________________________________________
I tried to put the thread in another class, I tried different
versions of Runnable & Thread, I tried to find an easy
solution in some tutorial, but nothing is working. I'd be
very happy to get a solution for this problem...
Thanks very much!
Yoshi Okamoto