1 19 20 package org.netbeans.modules.autoupdate; 21 22 import java.awt.Component ; 23 import javax.swing.ImageIcon ; 24 import javax.swing.JList ; 25 import javax.swing.JLabel ; 26 import javax.swing.DefaultListCellRenderer ; 27 28 32 class SelectedListCellRenderer extends DefaultListCellRenderer { 33 34 static final long serialVersionUID =-4278857657314562123L; 35 public Component getListCellRendererComponent( JList list, 36 Object value, 37 int index, 38 boolean isSelected, 39 boolean cellHasFocus) { 40 JLabel cr = (JLabel )super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus ); 41 42 if ( ((ModuleUpdate)value).isDownloadOK() ) 43 cr.setIcon( getProperIcon("ok") ); 44 else if ( ((ModuleUpdate)value).isPurchased() ) 45 cr.setIcon( getProperIcon("purchasedModule") ); 46 else if ( value instanceof L10NUpdate ) 47 cr.setIcon( getProperIcon("localeModule") ); 48 else 49 cr.setIcon( ((ModuleUpdate)value).isNew() ? getProperIcon("newModule") : getProperIcon("updateModule") ); 50 cr.setText( ((ModuleUpdate)value).getName() ); 51 52 return cr; 53 } 54 55 private ImageIcon getProperIcon(String type) { 56 return new ImageIcon ( org.openide.util.Utilities.loadImage( 57 "org/netbeans/modules/autoupdate/resources/" + type + ("updateModule".equals(type)? ".png": ".gif") ) 59 ); 60 } 61 } 62 | Popular Tags |