-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_spot.java
More file actions
53 lines (47 loc) · 1.16 KB
/
Copy pathimage_spot.java
File metadata and controls
53 lines (47 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class image_spot extends Applet implements ItemListener
{
CheckboxGroup cg;
Checkbox c1;
Checkbox c2;
Checkbox c3;
Checkbox c4;
Checkbox c5;
Label l1;
Image img;
public void init()
{
cg = new CheckboxGroup();
c1 = new Checkbox("Flower", cg, false);
c2 = new Checkbox("animal", cg, false);
c3 = new Checkbox("doll", cg, false);
c4 = new Checkbox("book", cg, false);
c5 = new Checkbox("chocolate", cg, false);
l1 = new Label("Who Is in the picture?");
img = getImage(getCodeBase(),"flower.jpg");
}
public void start()
{
add(l1);
add(c1); add(c2); add(c3); add(c4); add(c5);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
c4.addItemListener(this);
c5.addItemListener(this);
}
public void paint(Graphics g)
{
g.drawImage(img,50,200,this);
}
public void itemStateChanged(ItemEvent e)
{
Checkbox cb = cg.getSelectedCheckbox();
if (cb == c1)
showStatus("Correct answer");
else
showStatus("wrong");
}
}