import java.awt.* ; import java.awt.event.* ; /** *
*
Purpose: Simple drawing program with exit option. *
* *
Description: *
Draws a diagonal line in a window. *
* * @author Richard Akester * @version $Date: 2005/10/18$ * */ public class MyDrawLine extends Frame { static class DrawArea extends Panel { public void paint(Graphics g) { int xStart=0, yStart=0; // iterate along the longest side (to avoid dotted lines) if(WIDTH > HEIGHT) { // Calculate c (as in y=mx+c) avoiding divide by 0. int c= WIDTH==0? 0 : yStart - xStart*HEIGHT/WIDTH; int xEnd=xStart+WIDTH; for(int x=xStart; xHEIGHT, xStart<->yStart int c= HEIGHT==0? 0 : xStart - yStart*WIDTH/HEIGHT; int yEnd=yStart+HEIGHT; for(int y=yStart; y