Package com.screenrunner.ui

Source Code of com.screenrunner.ui.SplashScreen

/*
* (c) Copyright 2009 Tim Jenkins
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package com.screenrunner.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JProgressBar;
import javax.swing.SwingConstants;

import com.screenrunner.ScreenRunner;
import com.screenrunner.data.I18n;

/**
* @author Tim Jenkins
* Splash Screen for displaying image, version, status text, and startup progress
*
*/
public class SplashScreen extends JDialog {
 
  private static final long serialVersionUID = 1L;
 
  private JLabel statusLabel;
  private JLabel versionLabel;
  private JProgressBar progressBar;
 
  /**
   * @param image - Path to background image to display in splash screen
   * @param version - Version text to display
   * @param status - Initial status text to display
   */
  public SplashScreen(String image, String version, String status) {
    super((JFrame)null);
    setSize(400, 250);
    setUndecorated(true);
    setResizable(false);
    setIconImages(ScreenRunner.icons);
    setTitle(I18n.get("ui/splash/title"));
    URL imgURL = ScreenRunner.class.getClassLoader().getResource(image);
    JLayeredPane pane = new JLayeredPane();
    ImageIcon img = new ImageIcon(imgURL, "ScreenRunner");
    JLabel imgLbl = new JLabel(img);
    imgLbl.setVerticalAlignment(JLabel.TOP);
    imgLbl.setBounds(0, 0, 400, 250);
    versionLabel = new JLabel(version);
    versionLabel.setOpaque(false);
    versionLabel.setBackground(new Color(0.0f, 0.0f, 0.0f, 0.0f));
    versionLabel.setForeground(new Color(172, 252, 255));
    versionLabel.setBounds(18, 16, 364, 120);
    versionLabel.setHorizontalAlignment(JLabel.RIGHT);
    versionLabel.setVerticalAlignment(JLabel.BOTTOM);
   
    statusLabel = new JLabel(status);
    statusLabel.setOpaque(false);
    statusLabel.setBackground(new Color(0.0f, 0.0f, 0.0f, 0.0f));
    statusLabel.setForeground(new Color(172, 252, 255));
    statusLabel.setBounds(18, 16, 364, 210);
    statusLabel.setHorizontalAlignment(JLabel.LEFT);
    statusLabel.setVerticalAlignment(JLabel.BOTTOM);
   
    pane.add(versionLabel, 300);
    pane.add(statusLabel, 310);
    pane.add(imgLbl, 200);
    add(pane, BorderLayout.CENTER);
   
    progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
    add(progressBar, BorderLayout.SOUTH);
   
    setLocationRelativeTo(null);
  }
 
  /**
   * setVersionText(String)
   *  - Sets the version text on the splash screen
   * 
   * @param version - Version text to display
   */
  public void setVersionText(String version) {
    versionLabel.setText(version);
  }
 
  /**
   * setStatusText(String)
   *  - Sets the status text on the splash screen
   * 
   * @param status - Status text to display
   */
  public void setStatusText(String status) {
    statusLabel.setText(status);
  }
 
  /**
   * setProgress(int)
   *  - Sets the value of the progress bar on the splash screen
   * 
   * @param value - Percentage value of progress bar (0-100)
   */
  public void setProgress(int value) {
    progressBar.setValue(value);
  }
 
}
TOP

Related Classes of com.screenrunner.ui.SplashScreen

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.