
package interfazgrafica6;

import java.awt.Canvas;
import java.awt.Graphics;

public class AreaDibujo extends Canvas {
  private int x1, y1, x2, y2;
  private boolean primerDibujado = true;
  private boolean inicioLinea = false;

 public void paint(Graphics g) { 
    if (primerDibujado)
     { g.drawString("AREA DE DIBUJO", 250, 20);
       g.drawLine(1,1,649,1); 
       g.drawLine(1,1,1,394); 
       g.drawLine(649,1,649,394); 
       g.drawLine(1,394,649,394); 
       primerDibujado = false; 
     }
    
    if (inicioLinea)
     { g.drawLine(x1,y1,x2,y2);
       inicioLinea = false;
     }
  }


 public void update(Graphics g) { 
    paint(g);
  }

 
  void recibirCoordenadas1(int x1, int y1) {
    this.x1 = x1;
    this.y1 = y1;
    inicioLinea = true;
  }


 void recibirCoordenadas2(int x2, int y2) {
    this.x2 = x2;
    this.y2 = y2;
  }    
}
