JAVA   102
DrawExample
Guest on 9th February 2023 03:11:19 AM


  1. /**
  2.  * Write a description of class FaceDragger here.
  3.  *
  4.  * @author (your name)
  5.  * @version (a version number or a date)
  6.  */
  7. import objectdraw.*;
  8. import java.awt.*;
  9.  
  10. public class DrawExample extends WindowController
  11. {
  12.  
  13.     private Location prevPoint;
  14.     private FreehandLine myLine;
  15.    
  16.     public void begin() {
  17.        
  18.  
  19.              
  20.     }
  21.    
  22.     public void onMousePress(Location pt) {
  23.         prevPoint = pt;
  24.         myLine = new FreehandLine();
  25.     }
  26.    
  27.     public void onMouseDrag(Location pt) {
  28.         myLine.addSegment(new Line(prevPoint, pt, canvas));
  29.         prevPoint = pt;
  30.        
  31.     }
  32.  
  33.     public void onMouseExit(Location pt) {
  34.         myLine.hide();
  35.     }
  36.  
  37.    
  38.    
  39.  
  40.    
  41.    
  42. }

Raw Paste

Login or Register to edit or fork this paste. It's free.