public class ShapeIcon implements Icon
1: import java.awt.*;
2: import java.util.*;
3: import javax.swing.*;
5: /**
6: An icon that contains a moveable shape.
7: */
8: public class ShapeIcon implements Icon
9: {
10: public ShapeIcon(MoveableShape shape,
11: int width, int height)
12: {
13: this.shape = shape;
14: this.width = width;
15: this.height = height;
16: }
17:
18: public int getIconWidth()
19: {
20: return width;
21: }
23: public int getIconHeight()
24: {
25: return height;
26: }
28: public void paintIcon(Component c, Graphics g, int x, int y)
29: {
30: Graphics2D g2 = (Graphics2D) g;
31: shape.draw(g2);
32: }
34: private int width;
35: private int height;
36: private MoveableShape shape;
37: }