org.geworkbench.util
Class SplashBitmap

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by javax.swing.JWindow
                  extended by org.geworkbench.util.SplashBitmap
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer

public class SplashBitmap
extends javax.swing.JWindow

Displays a splash screen containing one bitmap file and an optional progress bar. The splash screen can be selected to be hidden after a certain amount of time, when the user clicks it or by calling a method.
The bitmap used is loaded from a file. Valid file formats are GIF, JPEG and PNG.
The progress bar can be determinate or indeterminate. When determinate, it completes when the set timeout has passed.
Everything including showing, configuration, updating and hiding the splash screen can also be done manually.

Example #1:

// specify a bitmap file
SplashBitmap splash = new SplashBitmap(pathToFileOnFilesystem);

// make it close when clicked
splash.hideOnClick();

// show the whole thing
splash.showSplash();


Example #2:

// specify a bitmap file
SplashBitmap splash = new SplashBitmap(new URL("http://some.host.and/file.png"));

// close after 2 seconds
splash.hideOnTimeout(2000);

// interrupt the timeout and close when the splash screen is clicked
splash.hideOnClick();

// add a progress bar that completes within these 2 seconds
splash.addAutoProgressBar();

// display a string in the progress bar
splash.setProgressBarString("loading...");

// show the whole thing
splash.showSplash();

Author:
Kai Blankenhorn <pub01@bitfolge.de>
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JWindow
javax.swing.JWindow.AccessibleJWindow
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JProgressBar bar
           
 
Fields inherited from class javax.swing.JWindow
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SplashBitmap(java.lang.String filename)
          Constructs a new splash screen with the bitmap from the given file name.
SplashBitmap(java.net.URL filename)
          Constructs a new splash screen with the bitmap from the given URL.
 
Method Summary
 void addAutoProgressBar()
          Adds a JProgressBar to the splash screen that is automatically updated.
 void addAutoProgressBarIndeterminate()
          Adds a indeterminate JProgressBar to the splash screen that will be updated while the splash screen is displayed.
Only one progress bar can be added to the splash screen at a time.
 void addManualProgressBar(int min, int max)
          Adds a JProgressBar to the splash screen that can be updated manually.
Only one progress bar can be added to the splash screen at a time.
 void addProgressBarPercent()
          Displays the percentage of progress in the progress bar.
 int getProgressBarValue()
          Gets the current value of the progress bar in this splash screen.
 void hideOnClick()
          Tells this splash screen to close when being clicked.
 void hideOnTimeout(int timeout)
          Tells this splash screen to close after a certain time has passed.
 void hideSplash()
          Hides this splash screen and stops all running timers.
 void setProgressBarString(java.lang.String text)
          Sets the string that is displayed in the progress bar.
 void setProgressBarValue(int value)
          Sets the value of the progress bar in this splash screen to a new value.
 void showSplash()
          Shows this splash screen.
 
Methods inherited from class javax.swing.JWindow
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update, windowInit
 
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, 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, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bar

protected javax.swing.JProgressBar bar
Constructor Detail

SplashBitmap

public SplashBitmap(java.net.URL filename)
Constructs a new splash screen with the bitmap from the given URL. To display this splash screen, use showSplash().

Parameters:
filename - the URL of the image file to display

SplashBitmap

public SplashBitmap(java.lang.String filename)
Constructs a new splash screen with the bitmap from the given file name. To display this splash screen, use showSplash().

Parameters:
filename - the name of the image file to display
Method Detail

showSplash

public void showSplash()
Shows this splash screen. The window will be centered on the screen. Notice that all timers will start when this method is called, not when they are set. The splash screen will be centered on the screen.


hideSplash

public void hideSplash()
Hides this splash screen and stops all running timers.


hideOnTimeout

public void hideOnTimeout(int timeout)
Tells this splash screen to close after a certain time has passed. A splash screen can also be set to be hidden on timeout and on click at the same time, either of which occurs first.

Parameters:
timeout - the time this splash screen is to be displayed in milliseconds

hideOnClick

public void hideOnClick()
Tells this splash screen to close when being clicked. A splash screen can also be set to be hidden on timeout and on click at the same time, either of which occurs first.


addAutoProgressBar

public void addAutoProgressBar()
Adds a JProgressBar to the splash screen that is automatically updated. The progress bar is configured so that its progress is complete when the timeout set by hideOnTimeout(int) has expired. Not specifying this timeout will let the progress bar complete as fast as possible.
Only one progress bar can be added to the splash screen at a time. Adding a second one will overwrite the first one.

See Also:
hideOnTimeout(int)

addAutoProgressBarIndeterminate

public void addAutoProgressBarIndeterminate()
Adds a indeterminate JProgressBar to the splash screen that will be updated while the splash screen is displayed.
Only one progress bar can be added to the splash screen at a time. Adding a second one will overwrite the first one.


addManualProgressBar

public void addManualProgressBar(int min,
                                 int max)
Adds a JProgressBar to the splash screen that can be updated manually.
Only one progress bar can be added to the splash screen at a time. Adding a second one will overwrite the first one.

Parameters:
min - the JProgressBar's minimum value
max - the JProgressBar's maximum value
See Also:
setProgressBarValue(int), getProgressBarValue()

setProgressBarValue

public void setProgressBarValue(int value)
Sets the value of the progress bar in this splash screen to a new value.

Parameters:
value - the new value of the progress bar

getProgressBarValue

public int getProgressBarValue()
Gets the current value of the progress bar in this splash screen.

Returns:
the current value of the progress bar

setProgressBarString

public void setProgressBarString(java.lang.String text)
Sets the string that is displayed in the progress bar. Setting it to an empty string will hide it. Setting it to null will restore the default behaviour (display percent).

Parameters:
text - the string to be displayed in the progress bar

addProgressBarPercent

public void addProgressBarPercent()
Displays the percentage of progress in the progress bar.