rendered paste body/* Custom cell renderer for the JList */
class MyCellRenderer extends JLabel implements ListCellRenderer {
public ImageIcon onlineIcn, offlineIcn;
public MyCellRenderer() {
setOpaque(true);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
ImageIcon onlineIcn = new ImageIcon("icons/status_online.png");
ImageIcon offlineIcn = new ImageIcon("icons/status_offline.png");
String s = value.toString();
//setText(s);
contact con = (contact) value;
setText(con.getName());
setIcon(con.getStatus().equals("online") ? onlineIcn : offlineIcn);
//setIcon(s.length() < 4 ? onlineIcn : offlineIcn); WORKS!
//setIcon(entry.getStatus().equals("online") ? onlineIcn : offlineIcn);
//setIcon(.getStatus().equals("online") ? onlineIcn : offlineIcn);
setBackground(isSelected ? Color.lightGray : Color.white);
setForeground(con.getStatus().equals("online") ? Color.green : Color.red);
return this;
}
}