Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: paintComponent(Graphics graphics) Date: Fri, 20 Feb 2015 16:42:27 -0800 Organization: A noiseless patient Spider Lines: 39 Message-ID: References: <3dba8d3b-34bb-4bd3-8768-78b138daca92@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 21 Feb 2015 00:41:43 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="aba33539224e5c782fe0c4053f7756fd"; logging-data="1429"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193+8wqtIiVIoWfglaSCU22" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: Cancel-Lock: sha1:f0PZ5I5oSUz3tdmuJd0mQbW9KEg= Xref: csiph.com comp.lang.java.programmer:31166 On 2/20/2015 4:15 PM, Knute Johnson wrote: > On 2/20/2015 11:13 AM, Doug Mika wrote: >> Hi >> >> I hope I can explain this clearly without getting into too much detail >> as the code in question is a couple of thousand of lines. So to >> begin, I have a JPanel to which I add JLabels and JComponents using >> JPanel's add() method. It works fine, but now I would like to print >> an image ON TOP of the added JLabels and JComponents. For this I >> manipulate my JPanel's paintComponent(Graphics graphics) method. In >> it I have something of the following sort: >> >> paintComponent(Graphics graphics){ >> Graphics2D g = (Graphics2D)graphics.create(); >> g.drawImage(image, 200, 200, null); >> g.dispose >> } >> >> >> This works in that in my JPanel I now have my "image" appear at >> position (200,200), BUT it appears underneath all my JLabels and >> JComponents. >> HOW can I make it appear ON TOP of the JLabels and JComponents in my >> JPanel? >> >> Many Thanks >> Doug >> > > I'm assuming you have a translucent image you want to draw over the > whole JPanel. Draw on the JFrame's glasspane. I think you will have to > make the glasspane visible. > > http://docs.oracle.com/javase/tutorial/uiswing/components/rootpane.html -- Knute Johnson