Make web site - 624 Graphics and Java2D Chapter 11 13 //

624 Graphics and Java2D Chapter 11 13 // set window’s title bar String and dimensions 14 public DrawArcs() 15 { 16 super( “Drawing Arcs” ); 17 18 setSize( 300, 170 ); 19 setVisible( true ); 20 } 21 22 // draw rectangles and arcs 23 public void paint( Graphics g ) 24 { 25 // call superclass’s paint method 26 super.paint( g ); 27 28 // start at 0 and sweep 360 degrees 29 g.setColor( Color.yellow ); 30 g.drawRect( 15, 35, 80, 80 ); 31 g.setColor( Color.black ); 32 g.drawArc( 15, 35, 80, 80, 0, 360 ); 33 34 // start at 0 and sweep 110 degrees 35 g.setColor( Color.yellow ); 36 g.drawRect( 100, 35, 80, 80 ); 37 g.setColor( Color.black ); 38 g.drawArc( 100, 35, 80, 80, 0, 110 ); 39 40 // start at 0 and sweep -270 degrees 41 g.setColor( Color.yellow ); 42 g.drawRect( 185, 35, 80, 80 ); 43 g.setColor( Color.black ); 44 g.drawArc( 185, 35, 80, 80, 0, -270 ); 45 46 // start at 0 and sweep 360 degrees 47 g.fillArc( 15, 120, 80, 40, 0, 360 ); 48 49 // start at 270 and sweep -90 degrees 50 g.fillArc( 100, 120, 80, 40, 270, -90 ); 51 52 // start at 0 and sweep -270 degrees 53 g.fillArc( 185, 120, 80, 40, 0, -270 ); 54 } 55 56 // execute application 57 public static void main( String args[] ) 58 { 59 DrawArcs application = new DrawArcs(); 60 61 application.setDefaultCloseOperation( 62 JFrame.EXIT_ON_CLOSE ); 63 } 64 65 } // end class DrawArcs Fig. 11.19 Demonstrating drawArcand fillArc(part 2 of 3). Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01

Leave a Reply