I have to make three checkboxes appear, and when I click one, a picture will appear, when I click checkbox 2, figure 2 will appear, and same for #3. Can't get it to work, don't know what I'm doing wrong. This is what I have for now:

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

public class  prueba extends Applet {
Image figuraa; Image figurab; Image  figurac;
Checkbox g1, g2, g3; CheckboxGroup g;
public void  init(){

figuraa = getImage(getDocumentBase(), "figura1.jpg");
figurab  = getImage(getDocumentBase(), "figura2.jpg");
figurac =  getImage(getDocumentBase(), "figura3.jpg");
g1 = new Checkbox ("Tylenol", g,  false);
g2 = new Checkbox ("Perro", g, false);
g3 = new Checkbox ("Cafe",  g, false);
}

public boolean action (Event e, Object o){

if  (e.target instanceof Checkbox)
if (g1.getState() == true )
g.drawImage  (figuraa,1,1,this);
else if (g2.getState() == true)
g.drawImage  (figurab,1,1,this);
else if (g3.getState() == true)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.