• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPanel repaint(): what does it do inside?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic