Source of House.java


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