🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1234

Re: how do I draw a JPG to a panel/container

#1234
From: PeterH
Date: Tue, 16 Apr 2002 19:52
37 lines
2498 bytes
Hi John.  I have one small question with this I'm hoping you can help me out
with (or anyone else for that matter :>).

In the JFrame object, there is a getGraphics() method.  How come I can't use
that to get a Graphics object and use the drawImage() from there?  I thought
it would be ok, but that's where all my probs started from.  In other words,
why do I have to code up a paintComponent() to get a Graphics object to use
the drawImage(), when there is one readily available from the
JFrame.getGraphics()?

I know, I know, it's a newbie question, but I'm learning! :>  Thanks.




"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:MPG.172579c5bd0dc2ea98b534@newsgroups.borland.com...
> On Sun, 14 Apr 2002 17:00:07 -0400, PeterH wrote:
>
> > I thought I could just use a drawImage() method, but I can't
> > seem to get it to work.  I can get it to work if I use an Icon
> > and a JLabel, but I was hoping to avoid using a JLabel for an
> > image.
> >
> > Can I draw an image to a container?  Thanks.
>
> Yes, you can draw an image on any Swing component.  Just override the
> paintComponent() method and draw it.
>
> --
> Regards,
>
> John McGrath [TeamB]
>
> ---------------------------------------------------
> Before sending me e-mail, please read:
>     http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <3cbc80fd$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-06!supernews.com!news.airnews.net!cabal11.airnews.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!logbridge.uoregon.edu!sfo2-feed1.news.algx.net!allegiance!news-out.spamkiller.net!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3cb9ef73$1_1@dnews> <MPG.172579c5bd0dc2ea98b534@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,422c9cef40be2392
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-04-16 13:07:50 PST
From: "PeterH" <!REMOVEBeforeSending!peter@pchenry.com>
Newsgroups: borland.public.jbuilder.java.api
References: <3cb9ef73$1_1@dnews> <MPG.172579c5bd0dc2ea98b534@newsgroups.borland.com>
Subject: Re: how do I draw a JPG to a panel/container
Date: Tue, 16 Apr 2002 15:52:32 -0400
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 66.46.195.190
Message-ID: <3cbc80fd$1_2@dnews>
X-Trace: dnews 1018986749 66.46.195.190 (16 Apr 2002 12:52:29 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-06!supernews.com!news.airnews.net!cabal11.airnews.net!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!logbridge.uoregon.edu!sfo2-feed1.news.algx.net!allegiance!news-out.spamkiller.net!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews