• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pause in Swing Applet  RSS feed

 
Billy Jean
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you adding the label to the applet?
 
Billy Jean
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I am
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
comment out this line and see how you go

//this.getContentPane().setLayout(null);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!