Re: To use paint or paintComponent?
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 16 Mar 2008 05:59:18 GMT
On Sat, 15 Mar 2008 13:44:34 -0700 (PDT), travel2light
<everything2light@xxxxxxxxxxx> wrote, quoted or indirectly quoted
someone who said :
Which is the right one to use for Swing components? I have always used
JPanels with a method paint(Graphics g) and then just called that
method using 'repaint()'. But after reading some of the discussions
here I found out that the correct way to go is to use
paintComponent(Graphics g). Why is this? What is the difference
between the two methods? Thanks for any advice.
See http://mindprod.com/jgloss/paintcomponent.html
http://mindprod.com/jgloss/paint.html
Yes, you should use paintComponent. calling super.paintComponent and
using setOpaque replaces the old update/paint mechanism.
You can trace the calls or look at the code in source.zip, but when I
did that, I could not understand what the new scheme bought them.
I just use it.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.
- Follow-Ups:
- Re: To use paint or paintComponent?
- From: Daniel Pitts
- Re: To use paint or paintComponent?
- References:
- To use paint or paintComponent?
- From: travel2light
- To use paint or paintComponent?
- Prev by Date: Re: To use paint or paintComponent?
- Next by Date: Location of image files in Java SRC
- Previous by thread: Re: To use paint or paintComponent?
- Next by thread: Re: To use paint or paintComponent?
- Index(es):
Relevant Pages
|
|