blob: 25f798dba52d4062dc91370027933e35c21e57c9 (
plain)
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
|
/* Schranke.java */
import java.awt.*;
import java.applet.*;
public class Schranke
extends Applet
{
private int[] dx;
private Color[] color;
public void init()
{
String tmp;
dx = new int[2];
try {
dx[0] = Integer.parseInt(
getParameter("redwidth")
);
dx[1] = Integer.parseInt(
getParameter("whitewidth")
);
} catch (NumberFormatException e) {
dx[0] = 10;
dx[1] = 10;
}
color = new Color[2];
color[0] = Color.red;
color[1] = Color.white;
}
public void paint(Graphics g)
{
int maxX = getSize().width;
int maxY = getSize().height;
int x = 0;
int flg = 0;
Polygon p;
while (x <= maxX+maxY/2) {
p = new Polygon();
p.addPoint(x,0);
p.addPoint(x+dx[flg],0);
p.addPoint(x+dx[flg]-maxY/2,maxY);
p.addPoint(x-maxY/2,maxY);
p.addPoint(x,0);
g.setColor(color[flg]);
g.fillPolygon(p);
x += dx[flg];
flg = (flg==0) ? 1 : 0;
}
}
}
|