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


Groups > comp.lang.java.programmer > #31164

Re: paintComponent(Graphics graphics)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: paintComponent(Graphics graphics)
Date Fri, 20 Feb 2015 18:58:59 -0500
Organization A noiseless patient Spider
Lines 35
Message-ID <mc8i00$qk7$1@dont-email.me> (permalink)
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:03:12 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="c50a9e5d554cfaba13eda1c71e805135"; logging-data="27271"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19co5yFVhKR+a6iXNIe6UlUa2/r8Q7XRDs="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0
In-Reply-To <3dba8d3b-34bb-4bd3-8768-78b138daca92@googlegroups.com>
Cancel-Lock sha1:fb5FP6sXiSZCu12s0qLitqgtm+E=
Xref csiph.com comp.lang.java.programmer:31164

Show key headers only | View raw


On 02/20/2015 02:13 PM, 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.

It would be very easy to create a small example program that
demonstrates your situation.

> 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
> }
>

Why are you creating and disposing of a Graphics object?

>
> 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?
>

Have you looked at any of the descendants of JComponent that
allow to manipulate the component Z order?

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

paintComponent(Graphics graphics) Doug Mika <dougmmika@gmail.com> - 2015-02-20 11:13 -0800
  Re: paintComponent(Graphics graphics) Jeff Higgins <jeff@invalid.invalid> - 2015-02-20 18:58 -0500
    Re: paintComponent(Graphics graphics) Brixomatic <brixomatic@yahoo.com> - 2015-02-21 18:55 +0100
  Re: paintComponent(Graphics graphics) Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-02-20 16:15 -0800
    Re: paintComponent(Graphics graphics) Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-02-20 16:42 -0800
      Re: paintComponent(Graphics graphics) Jeff Higgins <jeff@invalid.invalid> - 2015-02-20 19:55 -0500
        Re: paintComponent(Graphics graphics) Jeff Higgins <jeff@invalid.invalid> - 2015-02-20 20:14 -0500

csiph-web