Results 1 to 2 of 2
Thread: repaint() problems
- 10-28-2010, 11:18 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 5
- Rep Power
- 0
repaint() problems
I'm working on an analog clock that reads the current time with the GregorianCalender. My intent was to have my seconds hand move per second with the timer. So far, the seconds hand moves per second but the old seconds hands are visible along with the repainted seconds hand. I tried calling revalidate(), but that didn't do anything. I'll post my code, thank you!
Everything works now, thank you so much!Last edited by Isong; 10-28-2010 at 11:29 PM. Reason: Answered
- 10-28-2010, 11:22 PM #2
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
To repaint over an old image, you need to call the super's paintComponent method:
Java Code:class MovingClockComponent extends JPanel { public MovingClockComponent() { //... } //.. public void paintComponent(Graphics g) { [color="red"][b]super.paintComponent(g);[/b][/color] Graphics2D ga = (Graphics2D) g; // .....
Also, you'll want to read up on how to use code tags in this forum.
Suerte!
Similar Threads
-
repaint every
By 3xpr1ment in forum AWT / SwingReplies: 10Last Post: 03-23-2010, 05:39 PM -
Trying to do a simple repaint
By IYIaster in forum New To JavaReplies: 9Last Post: 10-14-2009, 10:30 PM -
repaint() problems
By Emily1100125 in forum AWT / SwingReplies: 5Last Post: 02-03-2009, 04:11 PM -
Problem in repaint
By Preethi in forum AWT / SwingReplies: 16Last Post: 03-18-2008, 08:10 PM -
Repaint problem
By swimberl in forum Java 2DReplies: 1Last Post: 02-16-2008, 09:12 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks