download Splash.java
Language: Java
Copyright: (C) 1998 Giao Nguyen.
LOC: 41
Project Info
JOS Media Player(josgui)
Server: SourceForge
Type: cvs
...a‑player\org\mschmidt\ncsu\
   GrabAndScrollLabel.java
   HelpPane.java
   JMPFileChooser.java
   JOSMediaPlayer.java
   JOSPlayer.java
   PatchedHTMLEditorKit.java
   SetupTheme.java
   SimpleLinkListener.java
   Splash.java
   StringResources.java
   Thumbnail.java
   TipOfTheDay.java
   Util.java

/**
 * $Id: Splash.java,v 1.1 2000/11/28 03:35:56 jazilla Exp $
 *
 * This class is a splash window. It automagically takes center stage.
 *
 *      To get in touch with the Java Mozilla team, check out:
 *       news://news.mozilla.org/netscape.public.mozilla.java
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "MozPL"); you may not use this file except in
 * compliance with the MozPL.  You may obtain a copy of the MozPL at
 * http://www.mozilla.org/NPL/
 *
 * Software distributed under the MozPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MozPL
 * for the specific language governing rights and limitations under the
 * MozPL.
 *
 * The Initial Developer of this code under the MozPL is Giao Nguyen.
 * Portions created by Giao Nguyen are Copyright (C) 1998 Giao Nguyen.
 * All Rights Reserved.
 *
 */
package org.mschmidt.ncsu;

import java.awt.*;
import javax.swing.*;
//import org.jazilla.javafe.StringResources;
//import org.jazilla.javafe.utils.ImageLoader;

/**
 * A simple class to display a splash screen in the center of the users screen.
 * 
 * @author Giao Nguyen, Last Modified By: $Author: jazilla $
 */
public class Splash extends JWindow
{
    /*
     * The inset from the bottom of the window.  This depends very much
     * on the image within which the status is to be displayed!
     */
    private final static int    STATUS_BOTTOM_INSET = 30;
    
	private JLabel status = new JLabel(" ");

    /**
     * Default constructor for Splash Window.
     *
     * Some of the logic is 'hardwired' even though it really depends on the
     * image.  If we wanted flexibility then we'd need to create an ImageXXX
     * that, given the status region, would return the predominant color or
     * average of colors in that region.  A Color map could then be used to
     * figure out what text color would provide good contrast.
     * 
     * I didn't do that... and mozilla doesn't do that.  Here's their code:
     *
	 *    // The splash screen background is black, so use white text
	 *      dc.SetBkColor(RGB(0,0,0));
	 *      dc.SetTextColor(RGB(255,255,255));
	 *
	 * Anyway, this is just to explain the motivation between the 'hardwired'
	 * values.  The same applies to the STATUS_BOTTOM_INSET defined above.
	 */
	public Splash() 
	{

		JLabel image = new JLabel(new ImageIcon(getClass().getResource("/images/Splash.gif")));
		status.setOpaque(false);
		//status.setBackground( Color.black );
		//status.setForeground( Color.white );
		status.setForeground(new Color(165, 5, 66));
		FontMetrics f = status.getFontMetrics(status.getFont());
		
        // Add widgets to content pane
        Container content_pane = getContentPane();
		content_pane.setLayout(null);
		content_pane.add(status); 
		content_pane.add(image); 

        Dimension image_size = image.getPreferredSize();

        // Splash size is set to image size
		setSize( image_size );
		
        // Layout widgets on content pane 
		image.setBounds( 0, 0, image_size.width, image_size.height );
        // Status has no size since it has no text.  We can, however,
        // fix its y-axis location.

	// Change by Al: Status fiex to width of the dialog so that when text changes
	// the status bar area doesn't contain any old text left over (contact al@alsutton.com
	// for more info)
		status.setLocation( 0 , getSize().height - f.getHeight() - STATUS_BOTTOM_INSET );
		Dimension statusSize = new Dimension( getSize().width, f.getHeight());
		status.setSize( statusSize );
		status.setHorizontalAlignment( SwingConstants.CENTER );

	    setLocation(findScreenCenter());
	}

	/**
	 * Display some text (like "loading xyz...")
	 * at the bottom of the Splash window
	 * @param key the key of the message (e.g. "label.loadingPreferences")
	 */
	public void setStatus(String key) 
	{
		status.setText(key);
	}

    private Point findScreenCenter() 
    {
		Dimension screenSize = 
	    	Toolkit.getDefaultToolkit().getScreenSize();
		Dimension mySize = getSize();
		Point fin = new Point(0, 0);

		fin.x = (screenSize.width - mySize.width) / 2;
		fin.y = (screenSize.height - mySize.height) / 2;
		return fin;
    }
}

/**
 * Revision history:
 * $Log: Splash.java,v $
 * Revision 1.1  2000/11/28 03:35:56  jazilla
 * Initial Release for Media Player
 *
 * Revision 1.5  2000/08/30 18:01:23  jazilla
 * All methods have been documented along with proper copyright information
 * included in the headers.
 *
 * Revision 1.4  2000/07/06 22:26:39  jazilla
 * Uses new spash image.
 *
 * Revision 1.3  2000/03/18 16:43:41  atripp
 * added interfaces
 *
 * Revision 1.2  2000/02/28 22:17:52  jazilla
 * Uses getResource() now to load image.
 *
 * Revision 1.1  1999/12/16 04:43:02  frodob
 * Moving to org.jazilla
 *
 * Revision 1.4  1998/12/23 17:00:31  alcvs
 * Changed status bar to clean up it's appearance
 *
 * Revision 1.3  1998/12/03 16:06:59  giao
 * Updates from randy and david.
 *
 * Revision 1.2  1998/10/30 17:23:48  giao
 * Swing naming.
 *
 * Revision 1.1  1998/10/14 21:16:39  atripp
 * moved AppManager.java, OnExitCallBack.java, and Splash.java from javafe to javafe/common
 *
 * Revision 1.2  1998/10/14 02:35:03  atripp
 * include image on splash window.
 *
 * Revision 1.1  1998/05/22 07:57:24  giao
 * This is really lame but it makes a splash screen thing in the
 * middle of the screen. You still need to fill the content pane.
 * Not quite complete yet as I haven't figured out all the details.
 *
 *
 *
 *    KNOWN BUGS/FRUSTRATIONS:
 *      - None, currently.
 */

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us