aspose file tools*
The moose likes Beginning Java and the fly likes add Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "add" Watch "add" New topic
Author

add

Jack Bolton
Ranch Hand

Joined: May 08, 2006
Posts: 65
Hi,
I'm working with this program that generates a random time, and has a Button that when pressed adds an hour to the random time.
But if I press the Button again, it does nothing.
What I want is that everytime i press the button it will continue to add one hour to the time.
What can I do?
thanks for any response...
the code:
ClockLabel.java

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39408
    
  28
You don't seem to use the ActionListener class at the bottom; as a Listener it is probably best for it not to extend a Swing Component.

Write class MyActionListener implements ActionListener etc. And give your classes and fields more informative names; you should be able to tell what a programming component does by reading its name.

What you have written in the actionPerformed method of the Action you are adding to the button only starts the clock. You haven't written anything to set it an hour forward. I think that is probably all you need to alter.
Jack Bolton
Ranch Hand

Joined: May 08, 2006
Posts: 65
Originally posted by Campbell Ritchie:


What you have written in the actionPerformed method of the Action you are adding to the button only starts the clock. You haven't written anything to set it an hour forward. I think that is probably all you need to alter.


Let me explain:
the actionPerformed method that i am adding to the button calls the c1.startClock2(); method, and that method calls the updateTime2() method, so updateTime2() does add an hour to the time.
But I want that the button continues to do add hour to the time, because right now if you press it again, it does nothing.
How do i solve that?
[ April 26, 2007: Message edited by: Jack Bolton ]
Jack Bolton
Ranch Hand

Joined: May 08, 2006
Posts: 65
so..
what can i do?

please help me..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39408
    
  28
Is your ticker supposed to show the time? You are starting the ticker before you update the time. Try changing that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: add