jList.setCellRenderer(new CompanyLogoListCellRenderer());生成一个DefaultListCellRenderer,把这个DefaultListCellRenderer set到List里就行了 class CompanyLogoListCellRenderer extends DefaultListCellRenderer {
private ImageIcon icon = new ImageIcon("icons/table.gif"); public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component retValue = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setIcon(icon);
return retValue;
}
}
private ImageIcon icon = new ImageIcon("icons/table.gif"); public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component retValue = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
setIcon(icon);
return retValue;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货