Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2723

Re: Graphics and JVMs

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Subject Re: Graphics and JVMs
Message-ID <7aca8eb4483d6@uwe> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1194276455.292195.36770@q3g2000prf.googlegroups.com>
References <1194276455.292195.36770@q3g2000prf.googlegroups.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 49
Date Wed, 27 Apr 2011 15:40:47 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918847 96.60.20.240 (Wed, 27 Apr 2011 10:40:47 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:40:47 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2723

Show key headers only | View raw


  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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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