Java JTable Row setToRowBackground(Component c, JTable table, int row)

Here you can find the source of setToRowBackground(Component c, JTable table, int row)

Description

set To Row Background

License

Open Source License

Declaration

public static void setToRowBackground(Component c, JTable table, int row) 

Method Source Code

//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()));
    }
}

Related

  1. packRows(JTable table, int start, int end, int margin)
  2. removeTableRows(DefaultTableModel model)
  3. rowToModelIndex(JTable table, int row)
  4. setRowLines(JTable table, int row, int lines)
  5. setTableSize(JTable table, float percentage, int rows)
  6. updateTableSizes(JTable table, int rows)
  7. writeRow(DefaultTableModel table, List data, int row)