Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting a clock to update correctly

 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys - new here, and to Java programming, and I'm having a bit of difficulty getting a clock program to update properly. As it stands now, the time will update between the time I run the program and click getTime which opens up the window where the clock is displayed. Once it's opened so I can look at the time, it stops updating. When I close it out - but don't recompile or anything like that - the timer restarts.

Below is my code for the two classes I have.

ClockDisplay (This is the one I will have to change)


NumberDisplay (Not really important, but just in case any cross-references are needed...


I think I need to attach a listener to the displayString at the end of my first batch of code. Problem is, I don't know how to do it...

Thanks for any help!
 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, a bit of an update - I put in a while loop that makes the counter to continue even when the program is visible. Now I'm just having a problem with getting the display to show correctly. If I do a System.out.println(displayString); that shows me that the counter is working properly. The displayString(); just doesn't show properly when you execute the getTime(); method.
 
D diller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Added in a timer so that it kind of works - see http://www.relaxinlax.com/clock1.JPG to get an idea of what is still not working.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic