ublic class TestCellRenderer extends JLabel implements TableCellRenderer {
List<Student> list=null;
public TestCellRenderer(List<Student> l){
super();
this.list=l;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object object,boolean isSelected, boolean hasFocus, int row, int column) {
Student s=list.get(row);
if(s.getPoints()>=90)
setIcon(new ImageIcon(getClass().getResource(okay_path)));
if(s.getPoints()<90)
setIcon(new ImageIcon(getClass().getResource(error_path)));
}
setHorizontalAlignment(JLabel.CENTER);
return this;
}
}
public JLabel setJLabel(int value){
JLabel l=new JLabel();
if(value>=90)
l.setIcon(new ImageIcon(getClass().getResource("...successpath")));
else if(value<90)
l.setIcon(new ImageIcon(getClass().getResource("...failedpath")));
return l;
}