Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Andrew Thompson" Subject: Re: Trying to put a backg Message-ID: <7dff8a0ce430d@uwe> X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <2KGdncI4_4zyZhjanZ2dnUVZ8sqjnZ2d@novis.pt> References: <2KGdncI4_4zyZhjanZ2dnUVZ8sqjnZ2d@novis.pt> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 69 Date: Wed, 27 Apr 2011 15:42:17 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918937 96.60.20.240 (Wed, 27 Apr 2011 10:42:17 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:42:17 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2985 To: comp.lang.java.gui Sabine Dinis Blochberger wrote: >Trying to put a background image in a JFrame > >I have looked this issue up and found that extending JPanel and >specifying a paintComponent() is one possibility. I haven't tried this >yet (and a different task popped up for today). I would recommend you try it, rather than.. >However, I thought that using the JFrames JRootPane or JLayeredPane >could be less a hassle. .'hack' JRootPane or JLayeredPane to achieve the (short term) visual effect. >..Well, it's not really, but I'm curious if this >could be solved. Possibly, but I doubt it could be done with more efficiency (expediency, or reusability) in the two components mentioned. >Get the whole NetBeans project with a compiled jar (49kB zip file) here >[1]. Please don't use the image for yourself, or my boss will kill me. You can alway supply a 'bogus' (white BG with a red 'X' crossing it) image for these test cases. In some (rare) instances, I have even 'hot linked' to Sun's* own images. * Example search.. >What happens is that the image (with transparent areas) is painted >infront of components instead of behind. The transparency whould be transparent, barring the root component being set to be 'opaque' (transparent=false). >..Actually, when I first start >the application, the image is infront of one button and behind the >other. Moving the mouse over a button brings it to front, resizing the >window will put all components behind the image. Have you called validate()/pack()? Or is this GUI relying on 'pure luck'? >By the way, in the final project, the window will not be resizable, >although I would appreciate some hint towards catering for the image >being anchored to the lower right corner aswell. Put it in an appropriate layout(s). A BorderLayout.WEST*, for the component, itself in a JPanel that is placed in the BorderLayout.SOUTH of an 'outer' panel, should achieve the 'lower left' constraint. * Assuming 'WEST' is left. I always forget. -- Andrew Thompson http://www.physci.org/ Message posted via http://www.javakb.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