Results 1 to 5 of 5
- 01-10-2012, 01:19 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 17
- Rep Power
- 0
paintComponents(g) instead of paintComponent(g)
I am reading the excellent book 'Introduction to Java Programming' from Y.Daniel Liang and suddenly he is starting to use super.paintComponents(g) instead of super.paintComponent(g) inside the overriden paintComponent(Graphics g) method.The problem is that he is not explaining why he is doing that.
I've found another similar thread with this one but I did not get the difference by reading that thread.
Thank you.Last edited by skiabox; 01-10-2012 at 02:12 PM.
-
Re: paintComponents(g) instead of paintComponents(g)
You're saying that he has you call the super.paintComponents method in the book not super.paintComponent? Are you 100% sure?
- 01-10-2012, 02:14 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 17
- Rep Power
- 0
Re: paintComponents(g) instead of paintComponents(g)
Yes in the chapter about JScrollPane he uses super.paintComponents(g).
In all previous chapters he was using super.paintComponent(g).
- 01-10-2012, 06:00 PM #4
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Re: paintComponents(g) instead of paintComponents(g)
It's possible that he wants to do some custom painting AFTER all the child components have been painted.
For example, maybe you want to paint a selection rectangle around a group of components. I've done this in the past by overriding the paint() method, not the paintComponents() method, but the effect might be the same.
- 01-10-2012, 10:53 PM #5
Member
- Join Date
- Jul 2011
- Posts
- 17
- Rep Power
- 0
Similar Threads
-
Why is java paintComponents() not working?
By jujubinaj in forum AWT / SwingReplies: 10Last Post: 12-20-2010, 01:26 PM -
paintComponent vs paintComponents
By alacn in forum New To JavaReplies: 5Last Post: 07-26-2010, 03:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks