/********************************************************************** * Simple.java an example of drawing points in Java * * To use, do * * javac Simple.java * java Simple * **********************************************************************/ import java.awt.*; // for Graphics import java.awt.event.*; // for WindowAdapter public class Simple extends Frame { public static void main(String args[]) { /* Create the Simple object. */ Simple sim = new Simple("Simple"); } /***** The constructor for Simple *****/ public Simple(String name) { /* Explicitly construct the Frame so that we can add the title. */ super(name); /* Add the windowClosing callback, so everything behaves when you /* close the application's window */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); }}); /* Specify the size of the frame and then make it visible. */ setSize(500,500); setVisible(true); } /***** This method is called whenever the Simple Frame must be redrawn. *****/ public void paint(Graphics gc) { /* Just draw two lines, point by point, to form an X. */ for (int i=50; i<300; i++) { gc.drawLine(i,i,i,i); // awt doesn't include a drawPoint method gc.drawLine(350-i,i,350-i,i); } } }