Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3276 > unrolled thread
| Started by | "travel2light" <travel2light@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:43 +0000 |
| Last post | 2011-04-27 15:44 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.java.gui
To use paint or paintComp "travel2light" <travel2light@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: To use paint or paint "Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: To use paint or paint "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
Re: To use paint or paint "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:44 +0000
| From | "travel2light" <travel2light@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:43 +0000 |
| Subject | To use paint or paintComp |
| Message-ID | <0fec8bfb-bf04-4384-82f2-2ffdcbcd4e11@s12g2000prg.googlegroups.com> |
To: comp.lang.java.gui 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. Michael --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Jeff Higgins" <jeff.higgins@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:43 +0000 |
| Subject | Re: To use paint or paint |
| Message-ID | <vHZCj.2025$qZ7.1200@newsfe07.lga> |
| In reply to | #3276 |
To: comp.lang.java.gui travel2light wrote: > 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. > > Michael <http://java.sun.com/products/jfc/tsc/articles/painting/index.html#callbacks> <http://java.sun.com/products/jfc/tsc/articles/painting/index.html> --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:43 +0000 |
| Subject | Re: To use paint or paint |
| Message-ID | <2mdpt3hd209unjq3ua4h6icgcnhemo2tv0@4ax.com> |
| In reply to | #3276 |
To: comp.lang.java.gui On Sat, 15 Mar 2008 13:44:34 -0700 (PDT), travel2light <everything2light@yahoo.co.uk> 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 --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:44 +0000 |
| Subject | Re: To use paint or paint |
| Message-ID | <47eb64c2$0$3996$7836cce5@newsrazor.net> |
| In reply to | #3278 |
To: comp.lang.java.gui Roedy Green wrote: > On Sat, 15 Mar 2008 13:44:34 -0700 (PDT), travel2light > <everything2light@yahoo.co.uk> 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. paint in JComponent is designed to call paintComponent and paintBorder, and handle delegation to the PLAF, as well as handle double buffering. If you override "paint" you basically create a "heavy-weight" AWT component rather than a "light-weight" Swing component. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/> --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web