// File: Drawing.java
// T Balls Feb 1998
// Demonstrate aspects of the
// java.awt.Graphics class in Java
import java.awt.*;
public class Drawing extends Frame
{ public Drawing()
{ setTitle( "Drawing" );
setSize( 400, 300 );
setVisible( true );
}
public void paint( Graphics g )
{ g.drawLine( 10, 30, 100, 200 );
g.setColor( Color.red );
g.drawRect( 10, 30, 50, 50 );
g.setColor( Color.blue );
g.fillRect( 100, 100, 30, 40 );
g.setColor( Color.green );
g.drawString( "Hello", 300, 150 );
}
}
class RunDrawing
{ public static void main( String[] args )
{ new Drawing();
}
}
|