Java JTable Color possiblyFixGridColor(JTable table)

Here you can find the source of possiblyFixGridColor(JTable table)

Description

Make a table use the right grid color on Windows Vista, when using the Windows Look and Feel.

License

BSD License

Parameter

Parameter Description
table The table to update.

Declaration

public static void possiblyFixGridColor(JTable table) 

Method Source Code

//package com.java2s;
/*//from www .j  ava  2s  . c  o m
 * 09/08/2005
 *
 * UIUtil.java - Utility methods for org.fife.ui classes.
 * Copyright (C) 2005 Robert Futrell
 * http://fifesoft.com/rtext
 * Licensed under a modified BSD license.
 * See the included license file for details.
 */

import java.awt.Color;

import javax.swing.JTable;

import javax.swing.UIManager;

public class Main {
    /**
     * Make a table use the right grid color on Windows Vista, when using the
     * Windows Look and Feel.
     *
     * @param table The table to update.
     */
    public static void possiblyFixGridColor(JTable table) {
        String laf = UIManager.getLookAndFeel().getClass().getName();
        if (laf.endsWith("WindowsLookAndFeel")) {
            if (Color.white.equals(table.getBackground())) {
                Color gridColor = table.getGridColor();
                if (gridColor != null && gridColor.getRGB() <= 0x808080) {
                    table.setGridColor(new Color(0xe3e3e3));
                }
            }
        }
    }
}

Related

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