Jonathan Viccary Jonathan Viccary - 2 months ago 6
Java Question

Removing gridlines from a table in Java but leaving a whole row the same color

I have used

TableCellRenderers
on a table to repaint cells so that every alternate row in a table is a different color, however, when I use
setShowGrid(false);
it removes the grid lines but allows the background color of the table to show through where the grid lines used to be, not the color of the cells in that row.

Is there a way to color these grid lines? Or do I need a better method of coloring the alternate rows?

Answer

You removed the lines but left the spacing. Removing the spacing should work.

jTable.setIntercellSpacing(new Dimension(0,0));