Article View: borland.public.jbuilder.java.language
Article #8382Re: Capture a drawing
From: John McGrath TeamB
Date: Wed, 28 Mar 2001 09:23
Date: Wed, 28 Mar 2001 09:23
25 lines
1532 bytes
1532 bytes
On Tue, 27 Mar 2001 16:53:34 +0200, Carlos Ojea Castro wrote:
> In my program I draw a picture and I
> want to "capture" it in a (image) variable.
> How can I do it?
You can create an Image and then use your paint() method to draw onto
the Image. The following code could be added to a Component to create
an image of itself:
public Image getImage() {
Dimension size = getSize();
Image image = createImage( size.width, size.height );
Graphics g = image.getGraphics();
paint( g );
}
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.152b575d3eec262598a0bf@forums.borland.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!sunqbc.risq.qc.ca!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!209.92.40.60References:
<3AC0A96E.B4E4C0DC@rslcom.es>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,89e485a02bd0a5ed X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-28 01:36:03 PST From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Capture a drawing Date: Wed, 28 Mar 2001 04:23:01 -0500 Message-ID: <MPG.152b575d3eec262598a0bf@forums.borland.com> References: <3AC0A96E.B4E4C0DC@rslcom.es> X-Newsreader: MicroPlanet Gravity v2.30 NNTP-Posting-Host: 209.92.40.60 X-Trace: 28 Mar 2001 01:18:32 -0800, 209.92.40.60 Lines: 25 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out-sjo.usenetserver.com!sunqbc.risq.qc.ca!nntp1.njy.teleglobe.net!teleglobe.net!hub.org!hub.org!PeerFeed.KWeb.on.ca!dnews!209.92.40.60