Java Reference
In-Depth Information
15
// start at 0 and sweep 360 degrees
16
g.setColor( Color.RED );
17
g.drawRect( 15 , 35 , 80 , 80 );
18
g.setColor( Color.BLACK) ;
19
g.drawArc( 15 , 35 , 80 , 80 , 0 , 360 );
20
21
// start at 0 and sweep 110 degrees
22
g.setColor( Color.RED );
23
g.drawRect( 100 , 35 , 80 , 80 );
24
g.setColor( Color.BLACK );
25
g.drawArc( 100 , 35 , 80 , 80 , 0 , 110 );
26
27
// start at 0 and sweep -270 degrees
28
g.setColor( Color.RED );
29
g.drawRect( 185 , 35 , 80 , 80 );
30
g.setColor( Color.BLACK );
31
g.drawArc( 185 , 35 , 80 , 80 , 0 , -270 );
32
33
// start at 0 and sweep 360 degrees
34
g.fillArc( 15 , 120 , 80 , 40 , 0 , 360 );
35
36
// start at 270 and sweep -90 degrees
37
g.fillArc( 100 , 120 , 80 , 40 , 270 , -90 );
38
39
// start at 0 and sweep -270 degrees
40
g.fillArc( 185 , 120 , 80 , 40 , 0 , - 270 );
41
}
42
} // end class ArcsJPanel
Fig. 13.24 | Arcs displayed with drawArc and fillArc . (Part 2 of 2.)
1
// Fig. 13.25: DrawArcs.java
2
// Drawing arcs.
3
import javax.swing.JFrame;
4
5
public class DrawArcs
6
{
7
// execute application
8
public static void main(String[] args)
9
{
10
// create frame for ArcsJPanel
11
JFrame frame = new JFrame( "Drawing Arcs" );
12
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
13
14
ArcsJPanel arcsJPanel = new ArcsJPanel();
15
frame.add(arcsJPanel);
16
frame.setSize( 300 , 210 );
17
frame.setVisible( true );
18
}
19
} // end class DrawArcs
Fig. 13.25 | Drawing arcs. (Part 1 of 2.)
Search WWH ::




Custom Search