Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Putting an Image inside a Panel

Reply
Thread Tools

Putting an Image inside a Panel

 
 
FuzzyLogic
Guest
Posts: n/a
 
      12-17-2005
I am writting an Applet (not a JApplet) and I have all the GUI ready,
with panels and panels inside panels. In one of this panels I need to
show an Image, but I can't work out how to do it. The image keeps
showing in the background of the applet, so the panels cover it. I have
tried:

Graphics gr=myPanel.getGraphics();
gr.drawImage(myImnage,0,0,null);

inside the paint() method, but It doesn't work.

Could you help me? I am just a beginner in Java.

Thanks
 
Reply With Quote
 
 
 
 
zero
Guest
Posts: n/a
 
      12-17-2005
FuzzyLogic <(E-Mail Removed)> wrote in news:S6Wof.125974$yg1.108478
@twister.auna.com:

> I am writting an Applet (not a JApplet) and I have all the GUI ready,
> with panels and panels inside panels. In one of this panels I need to
> show an Image, but I can't work out how to do it. The image keeps
> showing in the background of the applet, so the panels cover it. I have
> tried:
>
> Graphics gr=myPanel.getGraphics();
> gr.drawImage(myImnage,0,0,null);
>
> inside the paint() method, but It doesn't work.
>


You should draw the image from within the panel's paint method, not the
applet's paint.

Panel myPanel = new Panel()
{
public void paint(Graphics g)
{
g.drawImage(myImage, 0, 0, null);
}
};

applet.add(myPanel);

I think this should work.

--
Beware the False Authority Syndrome
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in putting webdatechooser infragistics control inside update panel muthukumar ASP .Net Web Controls 0 04-25-2006 01:07 PM
Delete a panel inside a panel (2) HS1 Java 4 12-08-2004 02:48 AM
Delete a panel inside a panel HS1 Java 3 12-07-2004 10:50 PM
Difference between putting code in constructor and putting code in static{} Saurabh Java 6 05-30-2004 02:44 PM
Putting a server side control inside an html element attribute John Lau ASP .Net 4 05-05-2004 12:42 AM



Advertisments