Class anAlbum


public class anAlbum
extends java.applet.Applet
implements java.lang.Runnable, java.awt.event.ActionListener

anAlbum Photo album applet. This can be used to show off your pictures on your homepage!
Has slideshow option and the viewer has next, previous, skip buttons also.
Very lightweight. No frills. Just does its job. I like it!

Applet Parameters:
SLIDESHOW: If the value is set to anything, slideshow is started by default.
FONT: The font to use for buttons and descriptions. In standard Java format. Example: Dialog-bold-12.
BGIMAGE: The background image to match your page background.
BGCOLOR: The background color to match your page background. In standard Java format. Example: #ffffff. Default is light gray.
FGCOLOR: The foreground color to match your page background. In standard Java format. Example: #ffffff. Default is black.
DELAY_SECS: Delay beween slideshows in seconds.
IMAGE0: The URL of the first image.
DESC0: The description for the first image. Default is empty string

Similarly IMAGE1, DESC1, IMAGE2, DESC2. Descriptions are not mandatory. Image and description numbers must be continuous.
You are free to use this code and to make modifications provided this notice is retained.

If you found this useful, please add a note of acknowledgement to my guestbook. If you would like to report a bug or suggest some improvements, you are most welcome. I will be happy to help you use this piece of code.

1.10, 10th Jun, 1999
Tanmay K. Mohapatra
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
Field Summary
private  java.awt.Color backgrColor
private  boolean bContinue
private  boolean bSlideShow
private  java.util.Vector descVect
private  java.awt.Button flipEnd
private  java.awt.Button flipNext
private  java.awt.Button flipPrev
private  java.awt.Button flipStart
private  java.awt.Color foregrColor
private  int iCurrImage
private  int iLastSuccessfulImage
private  java.util.Vector imageVect
private  java.awt.Image imgBackgr
private  long lDelay
private  java.awt.Image offScrBackgr
private  java.lang.Thread showThread
private  java.awt.Button slideStartStop
private  java.awt.Font textFont
private  java.awt.MediaTracker tracker
Fields inherited from class java.applet.Applet
serialVersionUID, stub
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
Constructor Summary
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Handle the button clicks
 void destroy()
          If slide show is enabled, signal the animator thread to stop.
 java.lang.String[][] getParameterInfo()
          Gives out parameter info if your browser supports it.
 void init()
          Read applet parameters and store them.
private  void nextLoaded()
          Go to the next loaded picture
 void paint(java.awt.Graphics gGraphics)
          Sets the description for the current image.
 boolean paintImageAt(java.awt.Graphics gGraphics, int iCurrImage)
          Sets the description for the specified image.
private  void prevLoaded()
          Go to the previous loaded picture
 void run()
          Paint the current image, sleep for delay seconds and advance to the next image.
private  void setSlideshowLabel()
          Check the slide show option and set the label accordingly.
 void start()
          If slide show to be done, create the animator thread and start it.
private  void startSlideShow()
          Start the slideshow.
 void stop()
          If slide show is enabled, signal the animator thread to stop.
private  void stopSlideShow()
          Stop the slideshow on its next cycle.
private  void toggleSlideShow()
          Start slideshow if stopped and stop if running.
 void update(java.awt.Graphics gGraphics)
          Just call the paint method.
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, validate, validateTree, writeObject
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait

Field Detail


private java.util.Vector imageVect


private java.util.Vector descVect


private boolean bSlideShow


private long lDelay


private java.awt.MediaTracker tracker


private int iCurrImage


private int iLastSuccessfulImage


private boolean bContinue


private java.lang.Thread showThread


private java.awt.Color backgrColor


private java.awt.Color foregrColor


private java.awt.Font textFont


private java.awt.Image imgBackgr


private java.awt.Image offScrBackgr


private java.awt.Button flipNext


private java.awt.Button flipPrev


private java.awt.Button flipStart


private java.awt.Button flipEnd


private java.awt.Button slideStartStop
Constructor Detail


public anAlbum()
Method Detail


public void init()
Read applet parameters and store them. Get all image URLs from the parameters and add the images to a media tracker. Create all components and layout the screen.
init in class java.applet.Applet


public void start()
If slide show to be done, create the animator thread and start it.
start in class java.applet.Applet


public void stop()
If slide show is enabled, signal the animator thread to stop.
stop in class java.applet.Applet


public void destroy()
If slide show is enabled, signal the animator thread to stop.
destroy in class java.applet.Applet


private void startSlideShow()
Start the slideshow.


private void stopSlideShow()
Stop the slideshow on its next cycle.


private void toggleSlideShow()
Start slideshow if stopped and stop if running.


private void setSlideshowLabel()
Check the slide show option and set the label accordingly.


public void update(java.awt.Graphics gGraphics)
Just call the paint method.
update in class java.awt.Container


public void paint(java.awt.Graphics gGraphics)
Sets the description for the current image. Paints the current image centered.
paint in class java.awt.Container


public boolean paintImageAt(java.awt.Graphics gGraphics,
                            int iCurrImage)
Sets the description for the specified image. Paints the specified image centered.


public void run()
Paint the current image, sleep for delay seconds and advance to the next image. Do this till not signalled to stop.
Specified by:
run in interface java.lang.Runnable


public void actionPerformed(java.awt.event.ActionEvent ae)
Handle the button clicks
Specified by:
actionPerformed in interface java.awt.event.ActionListener


private void prevLoaded()
Go to the previous loaded picture


private void nextLoaded()
Go to the next loaded picture


public java.lang.String[][] getParameterInfo()
Gives out parameter info if your browser supports it. JDK Appletviewer does.
getParameterInfo in class java.applet.Applet