Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

getting a clock to update correctly

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

reply
    Bookmark Topic Watch Topic
  • New Topic