1

I have a Java code and I want to show a waiting message during the elaboration. The program it's very long, I write a simply test to explain my problem:

public void actionPerformed(ActionEvent evt){
showMessage.yes();
for(int i = 0; i < 9999; i++)
    System.out.print("wait");
}

The method yes() only contain a JFrame.setVisible(true) command that should show a frame with the message "waiting". The problem is that in this case the frame is showed but the content of the frame (buttons, labels etc) doesn't show until the end of the for. Obviously if in this method I leave only the showMessage.yes() the frame is showed without problems...

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Davide
  • 11
  • 2
  • 4
    _Don't_ busy-wait on the EDT; _do_ see [*Concurrency in Swing*](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/) to [*How to Use Swing Timers*](http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html). – trashgod Mar 01 '14 at 23:28
  • 1
    See also [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Mar 01 '14 at 23:30
  • Sorry, I know that it's all written on the documentation, but I can't solve this problem. I use two method synchronized, with wait() and notify() but nothing. If I use another thread all starts well because the two threads work in parallel, but I can't catch when the another thread ended for close the JFrame. Even if I use an animated gif instead of JFrame the problem is the same, the gif appear freezed during the for... However thanks for reply! – Davide Mar 02 '14 at 10:46

0 Answers0