public class House extends JApplet
1: import javax.swing.JApplet;
2: import java.awt.Color;
3: import java.awt.Graphics;
4:
5: public class House extends JApplet
6: {
7: private int[] xHouse = {150, 150, 200, 250, 250};
8: private int[] yHouse = {100, 40, 20, 40, 100};
9: private int[] xDoor = {175, 175, 200, 200};
10: private int[] yDoor = {100, 60, 60, 100};
11: private int[] xWindow = {220, 220, 240, 240};
12: private int[] yWindow = {60, 80, 80, 60};
13:
14: public void paint(Graphics canvas)
15: {
16: super.paint(canvas);
17: this.setBackground(Color.LIGHT_GRAY);
18: canvas.setColor(Color.GREEN);
19: canvas.fillPolygon(xHouse, yHouse, xHouse.length);
20: canvas.setColor(Color.BLACK);
21: canvas.drawPolyline(xDoor, yDoor, xDoor.length);
22: canvas.drawPolygon(xWindow, yWindow, xWindow.length);
23: canvas.drawString("Home sweet home!", 150, 120);
24: }
25: }
26:
27:
28: