/*----------------------------------------------------------------------* * g0_brief2 DIS * * Basics of Graphics (reduced commentary) * * has constructor * *----------------------------------------------------------------------*/ import java.awt.*; public class g0_brief2 { public static void main (String[ ] args) { Drawing d = new Drawing(500,500); } // method main } // class g0_brief class Drawing extends Frame { // now using constructor: Drawing window(int w,int h) { setSize(w,h); // set window size to 500x500 pixels setBackground(Color.white); // set background color of window setTitle("G0 Example!"); // Place title in border of window show(); // must include to show window! } public void paint(Graphics g) { // Accomodate for the titlebar and left border of the window: g.translate(getInsets().left,getInsets().top); // Set foreground color -- the color of the image you're about // to draw: g.setColor(Color.blue); // Draw a rectangle with upper left corner at (0,0) and size // 100x100 pixels: g.drawRect(0,0,100,100); // Change the color of the next image g.setColor(Color.green); // Draw a filled-in oval at (200,300) and size (100,50) // (these dimensions refer to a bounding rectangle that // contains the oval): g.fillOval(200,300,100,50); } // method paint } // class Drawing