I have a JTable, the editor of the cells is JComboBox, i want to search for a value in the cells, once i found it, i want the cell to be shaded in a different color in order to notice it easily, How can i do that. Appreciate Your Help Thanks alot.
posted 12 years ago
not sure what overrides you have in place, but best way to do this is probably to write a custom cellrenderer. One way might be to override 'setValue' for the colorable columns. (Another way, not discussed here, might be to override getTableCellRendererComponent in the component) if your colorable cells are JLabels, for example, you could test the combobox value, and setForeground(someColor) to the appropriate color for the cell. very generally speaking, the renderer might look like: