0

I'm developing a simple java application using swing. I use JTable element. The problem is that by default rows of tables are white and grey like in this post Setting color in a row of a Jtable . I want to make them the same color, for example all rows white.

Community
  • 1
  • 1
  • The shoot is using Nimbus, this the default rendering method for Nimbus. You could implement your own TableCellRenderer to over write this, or you could change the color the Nimbus uses. Take a look at [this question](http://stackoverflow.com/questions/13008241/nimbus-and-alternate-row-colors) for details – MadProgrammer Apr 16 '13 at 20:26

1 Answers1

1

You can override the prepareRenderer method of JTable like this

JTable table = new JTable(...)
{
    public Component prepareRenderer(
        TableCellRenderer renderer, int row, int column)
    {
        Component c = super.prepareRenderer(renderer, row, column);
        c.setBackground(Color.WHITE);
        return c;
    }
};

Or you could create your own TableCellRenderer which does the same thing (picking the background color to render) but on a Cell level and use that renderer for each of your columns.

3xil3
  • 1,546
  • 1
  • 12
  • 16