Results 1 to 4 of 4
- 08-01-2012, 10:11 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 11
- Rep Power
- 0
How can I have two different types of timers in one program?
Is it even possible? I tried declaring
andJava Code:javax.swing.Timer newt=new Timer(1000, new ActionListener(){...});but it gives me the error: Type mismatch: cannot convert from javax.swing.Timer to java.util.Timer for the second. I have both types imported and I they are in different methods of the program.Java Code:java.util.Timer timer=new Timer();
EDIT: I realized that I only had the javax.swing.Timer; imported specifically. If it is not possible, then how can I use .scheduleAtFixedRate with a swing timer?Last edited by gregsakas; 08-01-2012 at 10:17 PM.
-
Re: How can I have two different types of timers in one program?
Rather than ask us to answer a specific code question, you may be better off first telling us what overall problem you're trying to solve and some background into your problem (for example, is this in fact for a Swing GUI?) as the best solution may vary depending on this.
- 08-02-2012, 02:44 PM #3
Member
- Join Date
- Aug 2012
- Posts
- 11
- Rep Power
- 0
Re: How can I have two different types of timers in one program?
I need one timer that can do:
and one timer that can do:Java Code:timer.scheduleAtFixedRate(...);
and as far as I know there isn't one timer that does both.Java Code:Timer newtimer=new Timer(1000, new ActionListener() { });
EDIT: They need to be in the same program. That's really all I need.
- 08-02-2012, 03:01 PM #4
Member
- Join Date
- Aug 2012
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
Use both Timer types in the same program
By Colonel Q in forum New To JavaReplies: 4Last Post: 12-04-2011, 07:05 PM -
Can Timers only have one task?
By CuddlyKittens11 in forum Advanced JavaReplies: 1Last Post: 05-21-2011, 06:50 AM -
I need help with timers
By Chris Rice in forum New To JavaReplies: 14Last Post: 03-07-2010, 09:04 PM -
Help - Swing Timers, Two Keypresses
By Gheta in forum AWT / SwingReplies: 2Last Post: 07-29-2009, 09:23 PM -
Question on swing timers
By Samgetsmoney in forum New To JavaReplies: 5Last Post: 02-20-2009, 07:34 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks