Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Color;

import javax.swing.JList;

import javax.swing.UIManager;

public class Main {
    private static Color backgroundColor;

    public static Color getBackgroundColor() {
        if (backgroundColor != null) {
            return backgroundColor;
        }

        backgroundColor = UIManager.getColor("Table.background");
        if (backgroundColor == null) {
            backgroundColor = new JList().getBackground();
        }
        //sometimes the UIManager color won't work
        backgroundColor = new Color(backgroundColor.getRed(), backgroundColor.getGreen(),
                backgroundColor.getBlue());

        return backgroundColor;
    }
}