public class ArcsJPanel extends JPanel
1: // Fig. 12.24: ArcsJPanel.java
2: // Drawing arcs.
3: import java.awt.Color;
4: import java.awt.Graphics;
5: import javax.swing.JPanel;
6:
7: public class ArcsJPanel extends JPanel
8: {
9: // draw rectangles and arcs
10: public void paintComponent( Graphics g )
11: {
12: super.paintComponent( g ); // call superclass's paintComponent
13:
14: // start at 0 and sweep 360 degrees
15: g.setColor( Color.RED );
16: g.drawRect( 15, 35, 80, 80 );
17: g.setColor( Color.BLACK );
18: g.drawArc( 15, 35, 80, 80, 0, 360 );
19:
20: // start at 0 and sweep 110 degrees
21: g.setColor( Color.RED );
22: g.drawRect( 100, 35, 80, 80 );
23: g.setColor( Color.BLACK );
24: g.drawArc( 100, 35, 80, 80, 0, 110 );
25:
26: // start at 0 and sweep -270 degrees
27: g.setColor( Color.RED );
28: g.drawRect( 185, 35, 80, 80 );
29: g.setColor( Color.BLACK );
30: g.drawArc( 185, 35, 80, 80, 0, -270 );
31:
32: // start at 0 and sweep 360 degrees
33: g.fillArc( 15, 120, 80, 40, 0, 360 );
34:
35: // start at 270 and sweep -90 degrees
36: g.fillArc( 100, 120, 80, 40, 270, -90 );
37:
38: // start at 0 and sweep -270 degrees
39: g.fillArc( 185, 120, 80, 40, 0, -270 );
40: } // end method paintComponent
41: } // end class ArcsJPanel
42:
43: /**************************************************************************
44: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
45: * Pearson Education, Inc. All Rights Reserved. *
46: * *
47: * DISCLAIMER: The authors and publisher of this book have used their *
48: * best efforts in preparing the book. These efforts include the *
49: * development, research, and testing of the theories and programs *
50: * to determine their effectiveness. The authors and publisher make *
51: * no warranty of any kind, expressed or implied, with regard to these *
52: * programs or to the documentation contained in these books. The authors *
53: * and publisher shall not be liable in any event for incidental or *
54: * consequential damages in connection with, or arising out of, the *
55: * furnishing, performance, or use of these programs. *
56: *************************************************************************/