Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Putting an Image inside a Panel

Thread view: 
FuzzyLogic - 17 Dec 2005 15:26 GMT
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
zero - 17 Dec 2005 17:02 GMT
FuzzyLogic <email@fake.is> 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
[quoted text clipped - 6 lines]
>
> 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.

Signature

Beware the False Authority Syndrome



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.