forked from ShivamDubey7/Competitive-Programming-Algos
-
Notifications
You must be signed in to change notification settings - Fork 315
/
Copy pathFigchoice.java
48 lines (48 loc) · 928 Bytes
/
Figchoice.java
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
import java.applet.*;
import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
public class figchoice extends Applet implements ItemListener {
Choice ch;
int x1[]= {50,120,220,20};
int y1[]= {50,120,20,20};
int n=4;
int Selection;
public void init()
{
ch = new Choice();
ch.addItem("Select a Shape");
ch.addItem("Rectangle");
ch.addItem("Triangle");
ch.addItem("Square");
ch.addItem("Circle");
add(ch);
ch.addItemListener(this);
}
public void itemStateChanged (ItemEvent e)
{
Selection = ch.getSelectedIndex();
repaint();
}
public void paint(Graphics g)
{
super.paint(g);
if (Selection == 1)
{ g.drawRect(50,50,100,150); }
if (Selection == 2)
{ g.drawPolygon(x1,y1,n); }
if (Selection == 3)
{ g.drawRect(50,50,100,100); }
if (Selection == 4)
{
g.drawOval(70,30,100,100);
} } }
<html><head>
</head>
<body>
<div align="center">
<applet code="figchoice.class"width="800"height="500">
</applet>
</div>
</body>
</html>