Here you can find the source of setToRowBackground(Component c, JTable table, int row)
public static void setToRowBackground(Component c, JTable table, int row)
//package com.java2s; /*/* w w w. j a v a2 s. co m*/ * TableCellUtilities.java * Copyright 2008 Connor Petty <cpmeister@users.sourceforge.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Created on Aug 10, 2008, 3:37:34 PM */ import java.awt.Color; import java.awt.Component; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; public class Main { private static final DefaultTableCellRenderer dummyRenderer = new DefaultTableCellRenderer(); public static void setToRowBackground(Component c, JTable table, int row) { dummyRenderer.getTableCellRendererComponent(table, null, false, false, row, 0); Color bg = dummyRenderer.getBackground(); // We have to create a new color object because Nimbus returns // a color of type DerivedColor, which behaves strange, not sure // why. c.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); } }