Java JTable Color setForegroundColor(final Component comp, final JTable table, boolean isSelected, Color fgColor)

Here you can find the source of setForegroundColor(final Component comp, final JTable table, boolean isSelected, Color fgColor)

Description

set Foreground Color

License

Open Source License

Declaration

protected static Component setForegroundColor(final Component comp, final JTable table, boolean isSelected,
            Color fgColor) 

Method Source Code


//package com.java2s;
/*//from   ww w  .ja  va2  s  . c om
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
 * 
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing the software, include this License Header Notice in each file.
 */

import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;

public class Main {
    public static Component setForegroundColor(final Component comp, final JTable table, boolean isSelected) {
        return setForegroundColor(comp, table, isSelected, null);
    }

    protected static Component setForegroundColor(final Component comp, final JTable table, boolean isSelected,
            Color fgColor) {
        if (isSelected) {
            comp.setForeground(table.getSelectionForeground());
        } else {
            comp.setForeground(fgColor == null ? table.getForeground() : fgColor);
        }
        return comp;
    }
}

Related

  1. getTableBackgroundColor(boolean colored)
  2. getTableGridColor()
  3. possiblyFixGridColor(JTable table)
  4. setBackgroundColor(final Component comp, final JTable table, boolean isSelected)
  5. setColors(final Component comp, final JTable table, boolean isSelected, Color bgColor, Color fgColor)