Java tutorial
//package com.java2s; import java.awt.Color; import javax.swing.JList; import javax.swing.UIManager; public class Main { private static Color foregroundColor; public static Color getForegroundColor() { if (foregroundColor != null) { return foregroundColor; } foregroundColor = UIManager.getColor("Table.foreground"); if (foregroundColor == null) { foregroundColor = new JList().getForeground(); } //sometimes the UIManager color won't work foregroundColor = new Color(foregroundColor.getRed(), foregroundColor.getGreen(), foregroundColor.getBlue()); //sometimes the UIManager color won't work return foregroundColor; } }