1 29 30 package it.businesslogic.ireport.gui.subdataset; 31 32 import it.businesslogic.ireport.SortField; 33 import javax.swing.DefaultListCellRenderer ; 34 import javax.swing.ImageIcon ; 35 import javax.swing.JLabel ; 36 37 41 public class SortFieldCellRenderer extends DefaultListCellRenderer { 42 43 static ImageIcon ascIcon; 44 static ImageIcon descIcon; 45 46 47 public SortFieldCellRenderer() { 48 if (ascIcon == null) ascIcon = new javax.swing.ImageIcon (getClass().getResource("/it/businesslogic/ireport/icons/datasource/arrow_down.png")); 49 if (descIcon == null) descIcon = new javax.swing.ImageIcon (getClass().getResource("/it/businesslogic/ireport/icons/datasource/arrow_up.png")); 50 } 51 52 public java.awt.Component getListCellRendererComponent(javax.swing.JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 53 54 java.awt.Component retValue; 55 56 retValue = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 57 58 if (value instanceof SortField && retValue instanceof JLabel ) 59 { 60 SortField sf = (SortField)value; 61 JLabel label = (JLabel )retValue; 62 label.setText( sf.getFieldName() ); 63 64 label.setIcon( sf.isDesc() ? descIcon : ascIcon ); 65 } 66 67 return retValue; 68 } 69 70 71 72 } 73 | Popular Tags |