0

I was wondering if there's a simple way to make a Dialog visible for a very short period of time and then have it turn invisible. Or even if there's a possibility to do this instantaneously.

Cheers, Kesh

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Keshava Murthy
  • 119
  • 1
  • 2
  • 12
  • You can use timer class. I am not sure what you really want. – akki0996 Aug 30 '13 at 14:46
  • 1
    Please have a look at this wonderful answer, regarding [Closing JOptionPane programatically](http://stackoverflow.com/a/18107432/1057230) by @kleopatra, you just don't need the second `if` statement in the `for` loop , for your use case :-) – nIcE cOw Aug 30 '13 at 15:03
  • 2
    possible duplicate of [Closing A JOptionPane Programatically](http://stackoverflow.com/questions/18105598/closing-a-joptionpane-programatically) – trashgod Aug 30 '13 at 19:21
  • Seems to be, you guys are right. Is Stack etiquette to delete the question if it's a duplicate? – Keshava Murthy Sep 02 '13 at 08:36

1 Answers1

0

In a method do this:

Thread t = new Thread() {
  public void run() {
    try {
     Thread.sleep(5000);
    }
    catch(Exception ex) {
    }
    dialog.setVisible(false);
  }
t.start();
dialog.setVisible(true);
GerritCap
  • 1,606
  • 10
  • 9
  • 2
    please to delete this answer, 1) in Java7 isn't something visible until Thread.sleep(int) ended, 2) doesn't work in Java6 because all event to EDT are flushed in one moment when Thread.sleep(int) ended, 3) too lazy to remember for another side effects Thread.sleep(int) + visibility + EDT – mKorbel Aug 30 '13 at 14:53