Hi guys,

I am trying to create a cell renderer that will set a background imagefor cells in a JTable I have created, depending on the data inside each cell.

I think I will be able to do the rest, but for now I just want to be able to put background images inside a cell using my cell renderer (right now I am only managing to change the background color).

anyone have an idea how to do this ?

public class MyImageCellRenderer extends DefaultTableCellRenderer {
 
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
         boolean isFocused, int row, int column) {
    	
    	 Component cell = super.getTableCellRendererComponent
         (table, value, isSelected, isFocused, row, column);
    	 

     cell.setBackground(Color.black);		
    			
return cell;
    			
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.