Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

update problem

 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have to include Clock within my GUI so I tried to make one. This clock working fine but its look like its not update() itself , I looked at the API and I know that Swing don�t use update() like AWT does , I have to deal whit the UI Delegate , can anyone help me to provide update() like functionality in swing based container?

thanks
Shay Gaghe

[This message has been edited by Shay Gaghe (edited October 25, 2001).]
 
Thomas Suer
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about invoking the repaint() method?
 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im sorry , above is the code:
thanks
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Three changes:
Change the paintComponent method to paint. Change the Frame to JFrame (don't mix awt and swing). Change the add to frame.getContentPane().add(). There is a problem with overlaying of the time but at least it gives you a start.
You could use the clearRect() method of Graphics.
[This message has been edited by Paul Stevens (edited October 25, 2001).]
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not just add a JLabel to the JPanel, showing the time? the setText() mehtod of JLabel is Thread safe.
(sorry, I just don't understand why you're using the paint methods in this case. if you want a special font or background, that's no problem with JLabel.)
chantal
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chantal, That would be too easy
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh, I'm so sorry. I'll shut up, next time. (s... I know I won't be able)
chantal
 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you both for your fantastic kindness
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic