Class SplashScreen

  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjavax.swing.JWindow
                  extended bycom.anthonyeden.lib.gui.SplashScreen
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer,

public class SplashScreen
extends javax.swing.JWindow

A simple splash screen which displays an image. The splash screen can be closed by a user mouse click if the closeOnClick field is true. The window will be automatically closed after a certain amount of time defined by the waitTime field.

This code is based on the splash screen described by Tony Colston in the Java World tip 104.

Anthony Eden
See Also:
Serialized Form

Nested Class Summary
Nested classes inherited from class javax.swing.JWindow
Nested classes inherited from class java.awt.Window
Nested classes inherited from class java.awt.Container
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
Field Summary
          The default wait time (3 seconds).
Fields inherited from class javax.swing.JWindow
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Component
Fields inherited from interface java.awt.image.ImageObserver
Constructor Summary
SplashScreen(javax.swing.ImageIcon image)
          Construct a splash screen with the given ImageIcon.
SplashScreen(javax.swing.ImageIcon image, java.awt.Frame f)
          Construct a new splash screen with the given ImageIcon and the given parent frame.
Method Summary
 void close()
          Close the splash screen.
 int getWaitTime()
          Get the amount of time to wait before automatically closing the spash screen.
 boolean isCloseOnClickAllowed()
          Return true if the user can close the splash screen by clicking on it.
 void setCloseOnClickAllowed(boolean closeOnClick)
          Set to true if the user can close the splash screen by clicking on it.
 void setWaitTime(int waitTime)
          Set the amount of time to wait before automatically closing the spash screen.
Methods inherited from class javax.swing.JWindow
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update, windowInit
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


public static final int DEFAULT_WAIT_TIME
The default wait time (3 seconds).

See Also:
Constant Field Values
Constructor Detail


public SplashScreen(javax.swing.ImageIcon image)
Construct a splash screen with the given ImageIcon.

image - The ImageIcon


public SplashScreen(javax.swing.ImageIcon image,
                    java.awt.Frame f)
Construct a new splash screen with the given ImageIcon and the given parent frame.

image - The ImageIcon
f - The parent frame
Method Detail


public void close()
Close the splash screen.


public boolean isCloseOnClickAllowed()
Return true if the user can close the splash screen by clicking on it.

True if the user is allowed to close splash screen


public void setCloseOnClickAllowed(boolean closeOnClick)
Set to true if the user can close the splash screen by clicking on it.

closeOnClick - Set to true to allow user to close splash screen


public int getWaitTime()
Get the amount of time to wait before automatically closing the spash screen.

The wait time in milliseconds


public void setWaitTime(int waitTime)
Set the amount of time to wait before automatically closing the spash screen.

waitTime - The wait time in milliseconds

Copyright (c) 2000-2003 Anthony Eden. All Rights Reserved.