我需要在不使用TableCellRenderer的情况下在Jtable单元格中添加图像。如果我使用以下代码表示它在该特定单元格中显示名称(字符串)而不是image.how来执行此操作?
ImageIcon Icon= new ImageIcon("Blank.gif");
table.setValueAt(Icon,1,0);
using renderer
class FRM_FLXD_ICON_ASSGN extends DefaultTableCellRenderer {
ImageIcon Icon;
public Component getTableCellRendererComponent(
JTable table, Object value, boolean selected, boolean focus,
int row, int col) {
if(selected == true){
Icon=new ImageIcon(getClass().getResource("Pointer.gif"));
}
else{
Icon=new ImageIcon(getClass().getResource("Blank.gif"));
}
this.setIcon(Icon);
return this;
}
}