Source of House.java


  1: 
  2: import javax.swing.*;
  3: import java.awt.*;
  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:         this.setBackground(Color.LIGHT_GRAY);
 17:         canvas.setColor(Color.GREEN);
 18:         canvas.fillPolygon(xHouse, yHouse, xHouse.length);
 19:         canvas.setColor(Color.BLACK);
 20:         canvas.drawPolyline(xDoor, yDoor, xDoor.length);
 21:         canvas.drawPolygon(xWindow, yWindow, xWindow.length);
 22:         canvas.drawString("Home sweet home!", 150, 120);
 23:     }
 24: }
 25: 
 26: 
 27: