Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #31167
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!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 19:55:44 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 37 |
| Message-ID | <mc8lad$4vq$1@dont-email.me> (permalink) |
| References | <3dba8d3b-34bb-4bd3-8768-78b138daca92@googlegroups.com> <mc8ikv$sig$1@dont-email.me> <mc8k87$1cl$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Sat, 21 Feb 2015 00:59:57 +0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="c50a9e5d554cfaba13eda1c71e805135"; logging-data="5114"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19v6FZBzyfuayT6sBVZR1gxaLjQ+0yL98w=" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 |
| In-Reply-To | <mc8k87$1cl$1@dont-email.me> |
| Cancel-Lock | sha1:eHfk8qzIjcTr7KwzS6w6I6aETpM= |
| Xref | csiph.com comp.lang.java.programmer:31167 |
Show key headers only | View raw
On 02/20/2015 07:42 PM, Knute Johnson wrote:
>> 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
>
Thank you. Your response prompted me to have another look.
<http://docs.oracle.com/javase/tutorial/uiswing/misc/jlayer.html#drawing>
So that from the example:
class WallpaperLayerUI extends LayerUI<JComponent> {
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
Graphics2D g2 = (Graphics2D) g.create();
int w = c.getWidth();
int h = c.getHeight();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, .5f));
g2.setPaint(new GradientPaint(0, 0, Color.yellow, 0, h, Color.red));
g2.fillRect(0, 0, w, h);
g2.dispose();
}
}
Which answers my question to the OP regards
create and dispose of graphics object.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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