Skip to content

Commit 03a7d92

Browse files
authored
Create DrawRect.java
1 parent a91f3d9 commit 03a7d92

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

DrawRect.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Draw a rectange using parameters passed via Applet
2+
3+
import java.awt,*;
4+
import java.applet.*;
5+
6+
/*<applet code = "DrawRect" width = 100, height = 100>
7+
<param name = "x" value = "100">
8+
<param name = "y" value = "100">
9+
<param name = "width" value = "200">
10+
<param name = "height" value = "300">
11+
</applet>*/
12+
13+
public class DrawRect extends Applet{
14+
int x1,y1,w,h;
15+
public void init(){
16+
x1 = Integer.parseInt(getParameter("x"));
17+
y1 = Integer.parseInt(getParameter("y"));
18+
w = Integer.parseInt(getParameter("width"));
19+
h = Integer.parseInt(getParameter("height"));
20+
}
21+
public void paint(Graphics g){
22+
g.drawRect(x1,y1,w,h);
23+
}
24+
}

0 commit comments

Comments
 (0)