Article View: borland.public.jbuilder.java.swing
Article #8582R: (SORRY FOR MY BAD ENGLISH) Problem with a class that inherits from CANVAS
From: Marco Sindoni
Date: Wed, 09 Aug 2000 00:00
Date: Wed, 09 Aug 2000 00:00
32 lines
1990 bytes
1990 bytes
Thanks Ian... I solve the problem... I'll explain :
class Pezzo extends Canvas. Pezzo have a constructor like this:
Pezzo(int x, int y, Image img)
x and y are coordinates and img is the image dislayed. (x,y) is the point on
the JFrame where I want to display the image.
Pezzo overrides pubic void paint(Graphics g) like this:
pubic void paint(Graphics g)
{
...
g.drawImage(img,x,y,this);
}
And this is the error!!! The correct code is: g.drawImage(img,0,0,this);.
The two system's coordinate origin are not the same. My error was this...so
the image was displayed out of the bounds of Pezzo.
(I hope you understand...sorry..I promise : I'll study english this autumn.
:) )
Thanks... Marco
Ian Atkinson <atkinson@labs.mot.com> wrote in message
398FFA72.75E702F7@labs.mot.com...
> Marco -
>
> without seeing your code this is just a guess, what i believe is
> happening is that the reason you only see the last object is because the
> others are hidden under that one - you can either: 1) make the Pezzo
> class transparent in places where the image is not or 2) modifiy pezzo
> to manage multiple images in the same area and then just use one pezzo
> object on the form.
>
> ian
Technical Details
Message-ID:
<8mrhf2$bav$1@lacerta.tiscalinet.it>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8mom9j$opo$1@pegasus.tiscalinet.it> <398FFA72.75E702F7@labs.mot.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,6a83300a81a5b522 X-Google-Attributes: gid111d45,public From: "Marco Sindoni" <msindoni@tiscalinet.it> Subject: R: (SORRY FOR MY BAD ENGLISH) Problem with a class that inherits from CANVAS Date: 2000/08/09 Message-ID: <8mrhf2$bav$1@lacerta.tiscalinet.it> X-Deja-AN: 656311356 References: <8mom9j$opo$1@pegasus.tiscalinet.it> <398FFA72.75E702F7@labs.mot.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-Complaints-To: newsadmin@tiscali.it X-Trace: lacerta.tiscalinet.it 965822754 11615 62.11.58.9 (9 Aug 2000 12:05:54 GMT) Organization: Tiscali Spa X-MSMail-Priority: Normal NNTP-Posting-Date: 9 Aug 2000 12:05:54 GMT Newsgroups: borland.public.jbuilder.java.swing