This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Graphics

 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When doing a painting in a JPanel, why we override paintComponent(Graphics g) method other than paint(Graphics g) method..??
What will happen if paint method has overriden...?
 
Maxim Karvonen
Ranch Hand
Posts: 121
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Ramesh.

JComponent paints border and inner components in it's paint method. If you override paint method in a JComponent then some content may appear to be missing.

Also read the Painting in AWT and Swing article. It describes when and which methods are called (including paint and paintComponent).
 
Rob Camick
Ranch Hand
Posts: 2584
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swing is different from AWT when it comes to painting.

You can also look at the Swing tutorial on Custom Painting for an explanation and painting examples.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic