/Users/lyon/j4p/src/bookExamples/ch26Graphics/draw2d/CircleComponent.java

1    package bookExamples.ch26Graphics.draw2d; 
2     
3    import java.awt.*; 
4     
5    public class CircleComponent 
6            extends Component { 
7     
8        CircleComponent(int w, int h) { 
9            setSize(w + 10, h); 
10       } 
11    
12       public void paint(Graphics g) { 
13           setBackground(Color.white); 
14           Point pt = getLocation(); 
15           Dimension d = getSize(); 
16           g.drawOval(0, 0, d.width, d.height); 
17       } 
18    
19       public static void main(String args[]) { 
20           ComponentMoveFrame f = new ComponentMoveFrame(); 
21           for (int i = 0; i < 10; i++) 
22               f.add(new CircleComponent(100, 100)); 
23           f.setVisible(true); 
24       } 
25    
26   }