/Users/lyon/j4p/src/ip/hak/LineComp.java

1    package ip.hak; 
2     
3    import java.awt.*; 
4     
5    public class LineComp extends Component { 
6        int x1,x2,y1,y2; 
7     
8        public LineComp(int xp1, int yp1, int xp2, int yp2) { 
9            x1 = xp1; 
10           x2 = xp2; 
11           y1 = yp1; 
12           y2 = yp2; 
13       } 
14    
15       public void setP1(int xp, int yp) { 
16           x1 = xp; 
17           y1 = yp; 
18           repaint(); 
19       } 
20    
21       public void setP2(int xp, int yp) { 
22           x2 = xp; 
23           y2 = yp; 
24           repaint(); 
25       } 
26    
27       public void paint(Graphics g) { 
28           g.drawLine(x1, y1, x2, y2); 
29       } 
30   }