Results 1 to 5 of 5
  1. #1
    Colonel Q is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Use both Timer types in the same program

    I would like to incorporate both timers (.swing for gui and .util for small delays) in a program I'm creating. Is this possible, or can I use one to do the work of the other?

    Thanks for any help.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Use both Timer types in the same program

    If you need to use both (can you explain what your problem is) you can.
    An easy way would be to use the full package path when defining the objects vs using import statements.

  3. #3
    Colonel Q is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default

    I'm trying to make a basic top down shooter game (basically Galaga), so I already have a swing timer employed. I was trying to find ways to make a firing rate for the player ship, but when I was trying the util Timer it wouldn't compile.

    In case it wasn't obvious, I'm rather inexperienced with programming, so if you can think of a better methodology I would appreciate it very much as well.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Use both Timer types in the same program

    it wouldn't compile.
    Have you tried the full package path when defining an object for the class?

    From the doc:
    java.util.Timer is more general and has more features. The javax.swing.Timer has two features that can make it a little easier to use with GUIs.
    What are your concerns in using timers?

  5. #5
    Colonel Q is offline Member
    Join Date
    Dec 2011
    Posts
    3
    Rep Power
    0

    Default Re: Use both Timer types in the same program

    I haven't tried using the full package path as I'm not sure how to do that. As for my concerns with using timers, I have none; I've been really happy with what I've been able to do with them so far, so I was trying to do it again. What I meant by "if you can think of a better methodology" is that I'm sure if there were an easier or more efficient way to operate you could tell me about it.

    Again, I appreciate any help you're willing to provide.

    EDIT: I'm going to try the full package path thing now. Wish me luck
    Last edited by Colonel Q; 12-04-2011 at 07:12 PM.

Similar Threads

  1. Stopping a Timer from Inside the timer
    By krishnan in forum Java Applets
    Replies: 2
    Last Post: 10-04-2010, 11:15 PM
  2. Timer Program.. please help!
    By lithium002 in forum New To Java
    Replies: 2
    Last Post: 03-08-2010, 06:58 PM
  3. writing a program launcher (or Timer)
    By Farzaneh in forum Threads and Synchronization
    Replies: 3
    Last Post: 02-17-2009, 09:00 AM
  4. Replies: 0
    Last Post: 04-04-2008, 02:46 PM
  5. Timer usage in java program
    By sandeeprao.techno in forum New To Java
    Replies: 5
    Last Post: 01-24-2008, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •