Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #2723
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Graphics and JVMs |
| Message-ID | <7aca8eb4483d6@uwe> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1194276455.292195.36770@q3g2000prf.googlegroups.com> |
| Date | 2011-04-27 15:40 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui sshark@gmail.com wrote: .. >I don't quite get what you commentede, > >// Except for Swing root components, use 'paint()'. >// but then, it is unwise to be rendering >// to root components. Better to render to a >// JPanel and add it to the root component. > >I suppose JFrame is the root or the lowest component of all the >components it contains. If so, why do you override paint(...) instead >of paintComponents(...) in the sample code above? OK - this ties in with my advice to 'not paint to root GUI components' (at all). 1) As mentioned above, JPanel is much more verstatile. A JPanel might be put in any 'root container' as well as other JPanels. Putting one JPanel in another is probably what you would need to do, to get the effect you are after. 2) The 'paint()/paintComponent()' breakdown between Swing and the AWT is effectively turned on its head by the root components (so it adds confusion/complexity to the mix). We might say "For AWT, override paint(), and for Swing, override paintComponent()" ..except for the irritating fact that with Swing you might *usually* override paintComponent(), except for those root components where it is paint(), such as JFrame, JWindow, JDialog, JOptionPane.. no ..wait, JOP inherits from JComponent and *has* a paintComponent() method - another inconsistency. A ll up, I think it is best to advise "with Swing custom painting, override paintComponent(Graphics) unless the compiler tells you there is 'no such symbol' on the method name, then override paint(Graphics)."! -- Andrew Thompson http://www.athompson.info/andrew/ Message posted via JavaKB.com http://www.javakb.com/Uwe/Forums.aspx/java-gui/200711/1 --- * 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
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Graphics and JVMs "sshark" <sshark@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "sshark" <sshark@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "sshark" <sshark@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Knute Johnson" <knute.johnson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "sshark" <sshark@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
Re: Graphics and JVMs "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
csiph-web