Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Click image

Status
Not open for further replies.

shomila

Technical User
Jan 5, 2007
5
0
0
GB
Hi,
i need some help..
i am trying to run a Java Applet and i think that the code that i need is in Java. I have loaded an image on the applet in java and i want to make it so that when you click on on this image(please note there are many images) an action is performed relating to this image

i have researched and i believe that to click on a certain image, you can use a hot spot. i have tried this but am getting fed up as its not working. could i please get some advice on whether to look into this further or to use something other than hotspots.
 
How did you load your image? If it's in a label, a mouselistener would do the trick.

Cheers,
Dian
 
i have used the following code:

public class Test extends Applet implements Loadable, HotSpotListener
{

RealMedia rm;
HotSpot hs1;
int x =1;

public void init()
{
setLayout(null);
setBackground(Color.white);
rm = new RealMedia(this);
rm.add("act.gif","imgACT");

rm.load();
}

public void startUp()
{
hs1 = new HotSpot(this);
hs1.setImage(rm.get("act.gif"),1);
hs1.setBounds(100,250,100,100);
add(hs1);
hs1.repaint();
}

public void paint(Graphics g)
{
g.drawImage(rm.get("imgACT"),100,200,this);

}

public void hotSpotEvent(HotSpot hs)
{
x = 1;
}

public Image loadImage(String file)
{
return getImage(getCodeBase(),file);
}

public AudioClip loadAudio(String file)
{
}
}

could you please help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top