Results 1 to 2 of 2
  1. #1
    Isong is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default 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

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Rep Power


    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)
    		Graphics2D ga = (Graphics2D) g;
    		// .....

    Also, you'll want to read up on how to use code tags in this forum.


Similar Threads

  1. repaint every
    By 3xpr1ment in forum AWT / Swing
    Replies: 10
    Last Post: 03-23-2010, 06:39 PM
  2. Trying to do a simple repaint
    By IYIaster in forum New To Java
    Replies: 9
    Last Post: 10-14-2009, 10:30 PM
  3. repaint() problems
    By Emily1100125 in forum AWT / Swing
    Replies: 5
    Last Post: 02-03-2009, 05:11 PM
  4. Problem in repaint
    By Preethi in forum AWT / Swing
    Replies: 16
    Last Post: 03-18-2008, 09:10 PM
  5. Repaint problem
    By swimberl in forum Java 2D
    Replies: 1
    Last Post: 02-16-2008, 10:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts