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)
2007-07-24
12:51:01
·
1 answers
·
asked by
jc_duque_h
1
in
Computers & Internet
➔ Programming & Design