1 32 33 package it.businesslogic.ireport.gui.sheet; 34 35 import java.awt.Color ; 36 import java.awt.Component ; 37 import java.awt.image.BufferedImage ; 38 import javax.swing.DefaultListCellRenderer ; 39 import javax.swing.JLabel ; 40 import javax.swing.JList ; 41 42 46 47 import java.awt.Color ; 48 import java.awt.Component ; 49 import java.awt.image.BufferedImage ; 50 import javax.swing.DefaultListCellRenderer ; 51 import javax.swing.JLabel ; 52 import javax.swing.JList ; 53 54 58 public class ColorsListCellRenderer extends DefaultListCellRenderer { 59 60 61 public ColorsListCellRenderer() { 62 super(); 63 } 64 65 66 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) 67 { 68 JLabel label = (JLabel )super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 69 70 if (value instanceof java.awt.Color ) 71 { 72 java.awt.Color color = (java.awt.Color )value; 73 74 label.setText("[" + color.getRed() + "," + color.getGreen() + "," + color.getBlue()+ "]" ); 75 label.setIcon(new ColorIcon(color)); 76 } 77 else 78 { 79 label.setIcon(new ColorIcon(java.awt.Color.WHITE)); 80 } 81 82 return label; 84 } 85 86 } 87 88 | Popular Tags |