0

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)
2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ezzaral
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.