-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdraw_shapes.java
More file actions
35 lines (35 loc) · 990 Bytes
/
Copy pathdraw_shapes.java
File metadata and controls
35 lines (35 loc) · 990 Bytes
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
import java.awt.*;
import javax.swing.*;
class draw_shapes extends Canvas {
int a;
draw_shapes() {
a=1;
}
public void paint(Graphics g) {
if(a==1) {
g.setColor(Color.GREEN);
g.drawRect(20,30,100,150);
g.fillRect(20,30,100,150);
g.setColor(Color.WHITE);
g.drawRect(30,40,80,130);
g.fillRect(30,40,80,130);
g.setColor(Color.BLUE);
g.drawOval(45,75,50,50);
g.fillOval(45,75,50,50);
g.setColor(Color.RED);
g.drawLine(140,30,140,100);
g.drawLine(180,30,180,100);
g.drawLine(140,30,180,100);
g.drawLine(180,30,140,100);
g.drawLine(140,100,180,100);
g.drawLine(140,30,180,30);
}
}
public static void main (String args[]){
draw_shapes d=new draw_shapes();
JFrame f=new JFrame();
f.add(d);
f.setSize(300, 300);
f.setVisible(true);
}
}