01: import java.awt.*; 02: import java.awt.geom.*; 03: import javax.swing.*; 04: 05: /** 06: An icon that has the shape of the planet Mars. 07: */ 08: public class MarsIcon implements Icon 09: { 10: /** 11: Constructs a Mars icon of a given size. 12: @param aSize the size of the icon 13: */ 14: public MarsIcon(int aSize) 15: { 16: size = aSize; 17: } 18: 19: public int getIconWidth() 20: { 21: return size; 22: } 23: 24: public int getIconHeight() 25: { 26: return size; 27: } 28: 29: public void paintIcon(Component c, Graphics g, int x, int y) 30: { 31: Graphics2D g2 = (Graphics2D) g; 32: Ellipse2D.Double planet = new Ellipse2D.Double(x, y, 33: size, size); 34: g2.setColor(Color.RED); 35: g2.fill(planet); 36: } 37: 38: private int size; 39: }