/Users/lyon/j4p/src/net/rmi/rmiimage/RectangleComponent.java

1    package net.rmi.rmiimage; 
2     
3    import java.awt.*; 
4     
5    public class RectangleComponent 
6        extends MovableComponent { 
7      private boolean on = true; 
8     
9      public RectangleComponent(boolean state) { 
10       on = state; 
11    
12    
13     } 
14    
15     public void setState(boolean _on) { 
16       on = _on; 
17       repaint(); 
18     } 
19    
20     public void paint(Graphics g) { 
21       setBackground(Color.white); 
22       Point pt = getLocation(); 
23       Dimension d = getPreferredSize(); 
24       if (on) 
25         g.fillRect(pt.x, pt.y, d.width, d.height); 
26       else 
27         g.drawRect(pt.x, pt.y, d.width, d.height); 
28     } 
29    
30   }