dcsimg
displaying images
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anu_Subramanion
Posted On:   Monday, September 17, 2001 03:19 AM

Hello how to display images using applets. I tried this .but this is not working.nothing is displayed, but the browser shows that the applet is running. import java.awt.*; import java.applet.*; public class dispimage extends Applet { Image img; public void init() { img =getImage(getCodeBase(),"bar.gif"); } public void paint(Graphics g) { g.drawImage(img,10,10,this); } } the gif file is in the directory as returned by the getCodeBase(). thanx in advance Regards Anu    More>>
			
Hello
how to display images using applets.
I tried this .but this is not working.nothing
is displayed, but the browser shows that
the applet is running.

import java.awt.*;
import java.applet.*;

public class dispimage extends Applet
{
Image img;
public void init()
{
img =getImage(getCodeBase(),"bar.gif");
}
public void paint(Graphics g)
{
g.drawImage(img,10,10,this);
}
}

the gif file is in the directory as returned
by the getCodeBase().

thanx in advance
Regards
Anu

   <<Less

Re: displaying images

Posted By:   Phil_Moore  
Posted On:   Monday, September 17, 2001 04:08 AM

I think you will have to call repaint() after loading the image.

This then asks the browser to call the applet's update() method,

which in turn will call your paint() method, and draw the image.



Cheers,
P

About | Sitemap | Contact