1 32 33 package it.businesslogic.ireport.chart.gui; 34 import it.businesslogic.ireport.chart.*; 35 import javax.swing.*; 36 import java.awt.*; 37 41 public class ChartCellRenderer extends javax.swing.DefaultListCellRenderer { 42 43 public static javax.swing.ImageIcon icon; 44 45 public ChartCellRenderer() { 46 super(); 47 if (icon == null) 48 { 49 icon = new javax.swing.ImageIcon (getClass().getResource("/it/businesslogic/ireport/icons/charts/pie3D.gif")); 50 } 51 } 52 53 public Component getListCellRendererComponent( 54 JList list, 55 Object value, 56 int index, 57 boolean isSelected, 58 boolean cellHasFocus) 59 { 60 JLabel label = (JLabel)super.getListCellRendererComponent(list,value,index,isSelected, cellHasFocus); 61 62 if (value instanceof ChartDefinition) 63 { 64 label.setText(""); 65 label.setIcon(((ChartDefinition)value).getIcon()); 66 67 } 68 else if (value instanceof ChartDescriptor) 69 { 70 label.setText(""); 71 label.setIcon(((ChartDescriptor)value).getIcon()); 72 73 } 74 return this; 75 } 76 } 77 78 | Popular Tags |