aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JPanel repaint(): what does it do inside? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel repaint(): what does it do inside?" Watch "JPanel repaint(): what does it do inside?" New topic
Author

JPanel repaint(): what does it do inside?

Castor Tack
Ranch Hand

Joined: Dec 06, 2010
Posts: 31
Hi,

I have no problem using repaint(). But I'm curious to know what it does inside.
Does it simply call the paintComponent() method again or do something special?
I can't imagine how the program will know what and how to repaint if it doesn't call my overridden paintComponent() method

Thanks for any explanations.


The BEST user interface design I've ever seen? --- A flush toilet.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Do you know that you have the source of all the JDK classes on your hard disk? Look in your JDK installation folder for a file src.zip.

You can see from the API that the repaint() method is inherited from Component. In Component, it calls repaint(long tm, int x, int y, int width, int height) with appropriate parameters. For AWT classes, that method either calls the same method of the Component's Container, or posts a PaintEvent to the EventQueue.

JComponent overrides the latter method to add a "dirty region" to the Swing RepaintManager, which pushes the painting requirement to the SystemEventQueue via SystemEventQueueUtilities.

Oh, and the outcome will be to invoke paint(...). Read the API for JComponent#paint(...) to see what that does.


luck, db
There are no new questions, but there may be new answers.
 
 
subject: JPanel repaint(): what does it do inside?