Basic HTML version of Foils prepared April 7 1998

Foil 9 Drawing a Rectangle with Java 2D

From Overview of Java2D and Java3D Frameworks CPS616 Web Technologies -- Spring 98. by Geoffrey C. Fox


1 public void paint( Graphics g ) {
2 Graphics2D g2d = ( Graphics2D ) g;
3 g2d.setColor( Color.red );
4 GeneralPath rect = new GeneralPath( GeneralPath.EVEN_ODD );
5 rect.moveTo( 300.0f, 300.0f ); // ul corner
6 rect.lineTo( 500.0f, 300.0f ); // ur corner
7 rect.lineTo( 500.0f, 400.0f ); // lr corner
8 rect.lineTo( 300.0f, 400.0f ); // ll corner
9 rect.closePath(); // close the rectangle
10 g2d.fill( rect );
11 }

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Nov 29 1998