Package de.timefinder.core.ui

Source Code of de.timefinder.core.ui.CustomProgressSplashScreen

/*
* This file is part of the TimeFinder project.
* Visit http://www.timefinder.de for more information.
* Copyright 2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.timefinder.core.ui;

import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JProgressBar;
import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.plaf.BorderUIResource.LineBorderUIResource;
import org.apache.commons.logging.LogFactory;
import org.springframework.richclient.application.splash.ProgressSplashScreen;

/**
* @author Peter Karich, peat_hal ‘at’ users ‘dot’ sourceforge ‘dot’ net
*/
public class CustomProgressSplashScreen extends ProgressSplashScreen {

    public CustomProgressSplashScreen() {
    }

    @Override
    protected JProgressBar getProgressBar() {
        try {
            Color oldSFGColor = (Color) UIManager.get("ProgressBar.selectionForeground");
            Color oldSBGColor = (Color) UIManager.get("ProgressBar.selectionBackground");
            Color oldFGColor = (Color) UIManager.get("ProgressBar.foreground");
            Color oldBGColor = (Color) UIManager.get("ProgressBar.background");
            Color oldBorderCol = ((LineBorder) UIManager.get("ProgressBar.border")).getLineColor();

            // recolor the progress bar, but only on startup
            Color myYellow = new Color(255, 225, 100);
            Color myGreen = new Color(120, 208, 60);

            UIManager.put("ProgressBar.selectionForeground", myYellow);
            UIManager.put("ProgressBar.selectionBackground", myGreen);
            UIManager.put("ProgressBar.foreground", myGreen);
            UIManager.put("ProgressBar.background", myYellow);
            UIManager.put("ProgressBar.border", new LineBorderUIResource(myYellow));

            // create the progressbar
            JProgressBar progressBar = super.getProgressBar();
            progressBar.setForeground(myGreen);
            progressBar.setBackground(myYellow);
            progressBar.setBorder(BorderFactory.createLineBorder(myYellow));

            // restore the default colors
            UIManager.put("ProgressBar.selectionForeground", oldSFGColor);
            UIManager.put("ProgressBar.selectionBackground", oldSBGColor);
            UIManager.put("ProgressBar.foreground", oldFGColor);
            UIManager.put("ProgressBar.background", oldBGColor);
            UIManager.put("ProgressBar.border", new LineBorderUIResource(oldBorderCol));

            return progressBar;
        } catch (Exception ex) {
            LogFactory.getLog(getClass()).debug(ex);
            return super.getProgressBar();
        }
    }
}
TOP

Related Classes of de.timefinder.core.ui.CustomProgressSplashScreen

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.