0

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;
    			
  }

Edited by daniiii: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by daniiii
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.