Results 1 to 2 of 2
  1. #1
    ellias2007 is offline Member
    Join Date
    Feb 2010
    Posts
    25
    Rep Power
    0

    Default for More TIMER control...

    Hi all,

    in the list of methods of the javax.swing Timer Class :

    Java Platform SE 7 b97

    i expect the existence of the following 2 methods (or like) :

    1) void setRepeats(int SpecificTimes)

    This method tells the timer to send exactlly a "Specific Number" action events to its listeners,
    So the action will be executed as many times as the user needs.


    2) int getDoneTimes()

    When called, This method returns the number of times the Action is done (till the moment)...

    Really it is nice to get such service from such Methods (or an equivalent code doing the job)
    in order to control more and more the work of Timer class...

    Is there an equivalent ??

    (May be it exists but i don't know?!:confused:)

    Thanks for any help

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    It's easy to give your Timer this functionality. One way would be to create a counter variable that is advanced each time the actionPerformed is called, would give this counter a public getter() method and also have an if block in the actionPerformed that stops the timer once count > MAX_COUNT. Note that the Timer object itself can be accessed from the actionPerformed via the ActionEvent's getSource() method.

Similar Threads

  1. Need help with timer
    By firecat318 in forum New To Java
    Replies: 6
    Last Post: 05-31-2010, 02:38 AM
  2. EJB Timer
    By mrjunsy in forum Advanced Java
    Replies: 0
    Last Post: 08-22-2008, 04:09 PM
  3. EJB Timer
    By mrjunsy in forum New To Java
    Replies: 0
    Last Post: 08-04-2008, 06:47 PM
  4. control app width based on certain control
    By thebillybobjr in forum SWT / JFace
    Replies: 0
    Last Post: 05-15-2008, 04:52 PM
  5. Replies: 0
    Last Post: 04-04-2008, 02:46 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
  •