9 Replies - 404 Views - Last Post: 18 April 2011 - 05:57 PM Rate Topic: -----

#1 kochu_suja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 06-April 11

Want to stop the frame for a second

Posted 17 April 2011 - 07:05 PM

Hai everybody...

I created frames to enter some data.That is,i first created a frame to enter name,number of actors.
Then using the number of actors,created frame to enter their actions and this loop continues
up to a limit.But all the time only the frame for entering the name and number of actors appears
and i entered the datas and frame for entering their actions appears and suddenly disappears.
What can i do to stop the frame for a second.

Waiting for a reply
Thanks..

Is This A Good Question/Topic? 0
  • +

Replies To: Want to stop the frame for a second

#2 JeremyC  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 80
  • Joined: 12-September 10

Re: Want to stop the frame for a second

Posted 17 April 2011 - 07:25 PM

Try this
 
try {
    Thread.sleep(1000);
} catch (InterruptedException e) { }



This post has been edited by JeremyC: 17 April 2011 - 07:25 PM

Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Want to stop the frame for a second

Posted 17 April 2011 - 09:25 PM

View PostJeremyC, on 17 April 2011 - 09:25 PM, said:

Try this
 
try {
    Thread.sleep(1000);
} catch (InterruptedException e) { }



Sorry but not a good idea at all to call Thread.sleep() in a Swing environment
What do you mean by "stopping a frame" ?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10367
  • View blog
  • Posts: 38,403
  • Joined: 27-December 08

Re: Want to stop the frame for a second

Posted 17 April 2011 - 09:33 PM

Take a look at the Swing Timer class.

@JeremyC: Invoking Thread.sleep() could cause the EventDispatchingThread to sleep, which could freeze your GUI as the EventDispatchThread controls it. Check out my blog entry on the Java GUI for alternatives to Threads with Swing.
Was This Post Helpful? 2
  • +
  • -

#5 kochu_suja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 06-April 11

Re: Want to stop the frame for a second

Posted 17 April 2011 - 09:48 PM

View Postpbl, on 17 April 2011 - 09:25 PM, said:

View PostJeremyC, on 17 April 2011 - 09:25 PM, said:

Try this
 
try {
    Thread.sleep(1000);
} catch (InterruptedException e) { }



Sorry but not a good idea at all to call Thread.sleep() in a Swing environment
What do you mean by "stopping a frame" ?

Quote

I want to stop the thread .

Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10367
  • View blog
  • Posts: 38,403
  • Joined: 27-December 08

Re: Want to stop the frame for a second

Posted 17 April 2011 - 09:53 PM

Why do you want to stop the EventDispatchingThread when there are better options available? You are playing with fire here.
Was This Post Helpful? 0
  • +
  • -

#7 JeremyC  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 80
  • Joined: 12-September 10

Re: Want to stop the frame for a second

Posted 18 April 2011 - 02:07 PM

Thank you for the info, learn something new every day.
Was This Post Helpful? 0
  • +
  • -

#8 kochu_suja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 06-April 11

Re: Want to stop the frame for a second

Posted 18 April 2011 - 05:47 PM

View Postmacosxnerd101, on 17 April 2011 - 09:53 PM, said:

Why do you want to stop the EventDispatchingThread when there are better options available? You are playing with fire here.

Quote

No,I just want to stop the for entering data.
That is,I want to enter data into the textfields.

Was This Post Helpful? 0
  • +
  • -

#9 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10367
  • View blog
  • Posts: 38,403
  • Joined: 27-December 08

Re: Want to stop the frame for a second

Posted 18 April 2011 - 05:49 PM

First, please stop posting your replies in quote tags. Use quote tags when quoting OTHER people's responses.

Second, GUI Components by default do not simply "go away," so there is no need to freeze the EventDispatchingThread. They will still be there for data entry until the user interacts with them by closing them, or something similar.
Was This Post Helpful? 1
  • +
  • -

#10 kochu_suja  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 06-April 11

Re: Want to stop the frame for a second

Posted 18 April 2011 - 05:57 PM

View Postmacosxnerd101, on 18 April 2011 - 05:49 PM, said:

First, please stop posting your replies in quote tags. Use quote tags when quoting OTHER people's responses.

Second, GUI Components by default do not simply "go away," so there is no need to freeze the EventDispatchingThread. They will still be there for data entry until the user interacts with them by closing them, or something similar.



Sorry.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1