drawlines

drawlines - last = new GPoint(e.getPoint()); gline = new

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import acm.graphics.*; import acm.program.*; import acm.util.*; import java.applet.*; import java.awt.*; import java.awt.event.*; public class drawlines extends GraphicsProgram{ public void run(){ // gline.setStartPoint(0,0); // gline.setEndPoint(200,200); // add(gline); addMouseListeners(); } // Called on mouse press to record the coordinates of the click */ public void mousePressed(MouseEvent e) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: last = new GPoint(e.getPoint()); gline = new GLine(e.getX(),e.getY(),e.getX(),e.getY()); add(gline); } // Called on mouse drag to reposition the object public void mouseDragged(MouseEvent e) { gline.setEndPoint(e.getX(),e.getY()); } /* Private instance variables */ private GLine gline; private GPoint last; }...
View Full Document

This note was uploaded on 10/25/2010 for the course CS 106A taught by Professor Sahami,m during the Fall '08 term at Stanford.

Ask a homework question - tutors are online