1 32 33 package it.businesslogic.ireport.gui.sheet; 34 import java.awt.*; 35 import javax.swing.*; 36 37 public class ColorIcon implements Icon, SwingConstants { 38 private int width = 32; 39 private int height = 14; 40 private java.awt.Color theColor = java.awt.Color.WHITE; 41 42 public ColorIcon(java.awt.Color c) { 43 theColor = c; 44 } 45 46 public int getIconHeight() { 47 return height; 48 } 49 50 public int getIconWidth() { 51 return width; 52 } 53 54 public void paintIcon(Component c, Graphics g, int x, int y) { 55 56 Color c1 = theColor; 57 Color c2 = Color.BLACK; 58 59 if (theColor == null) 60 { 61 c1 = Color.WHITE; 62 c2 = Color.GRAY; 63 } 64 g.setColor(c1); 65 66 g.translate(x, y); 67 g.fillRect(0, 0, width-1, height-1); 68 g.setColor(c2); 69 g.drawRect(0, 0, width-1, height-1); 70 g.translate(-x, -y); } 72 } 73 | Popular Tags |