• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Pause in Swing Applet

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to use Thread.sleep(1000) in a swing applet but its not working the way I want. I read that I have to use the javax.swing.timer class. I've read several tutorials on this, but I still can't seem to get it to work. Is there an easy way I can use javax.swing.timer or anything else to emulate the Thread.sleep(1000) functionality? Thank you.




Basically I need something like this, except thread.sleep doesnt work. How can I implement this with a swing timer or some other way? Thank You.



I tried declaring the following timer in my applet's init method:



and then I call flipTimer.start(); in the actionPerformed method, however this doesnt cause jLabel1 to be set. What am I doing wrong?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you adding the label to the applet?
 
Billy Jean
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes I am
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this works OK, compare to see what's different

 
Billy Jean
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whenever I place flipTimer.start() in the public void start() method, the applet fails to load completly, when I place it in the actionperformed method, it doesnt do anything.


Heres what I have:



this causes the applet to not even load, the java console gives the following error:

Any suggestions? thanks

[ August 30, 2005: Message edited by: Billy Jean ]
[ August 30, 2005: Message edited by: Billy Jean ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
comment out this line and see how you go

//this.getContentPane().setLayout(null);
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic