• Post Reply Bookmark Topic Watch Topic
  • New Topic

paintComponent()

 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i'd like to ask what is tyhe difference between
paint() and paintComponent() methods.
Am i right if i say that paintComponent() is used when dealing with let's say MouseEvents ?
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could just have a look at the source code. It is part of every JDK.
chantal
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In AWT, paint() did all the graphics for the component. In Swing, paint() calls the paintComponent(), paintChildren(), paintBorder(), etc. methods, and they are in charge of doing the painting of different things in the component. paintComponent() behaves pretty much like paint() in AWT... it paints the component... for more info on overriding paint routines of Swing components, look here...
 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you.
i think that i am starting to understand
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!