*/
public class DownloadsTableCellRenderer extends AlternatingColorTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, columnIndex);
Download download = (Download) value;
switch (columnIndex) {
case 0:
label.setText(download.getDescription());
label.setToolTipText(download.getUrl());
break;
case 1:
String text = download.getState().name();
if (Downloading.equals(download.getState()) || Processing.equals(download.getState()) || Resuming.equals(download.getState()))
text += " (" + download.getPercentage() + "%)";
label.setText(text);
label.setToolTipText(download.getUrl());
break;
default:
throw new IllegalArgumentException("Row " + rowIndex + ", column " + columnIndex + " does not exist");
}
return label;