I want to show a message in a JWindow for a while, so I tryed to use while() and sleep() functions, but it doesn't work. This is the function that should call JWindow ( MessageWindow ). Is there any other way to show this window for 2 seconds?
private void showJWindow() {
boolean flag = true;
final MessageWindow window = new MessageWindow( playerName, playerInAction );
window.setVisible( true );
try {
synchronized( window ) {
while( flag ) {
window.wait( 3000 );
flag = false;
window.setVisible( false );
}
}
} catch( InterruptedException ie ) {
Thread.currentThread().interrupt();
}
}