Class anAlbum

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--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.

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

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
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
anAlbum()
           
 
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

imageVect

private java.util.Vector imageVect

descVect

private java.util.Vector descVect

bSlideShow

private boolean bSlideShow

lDelay

private long lDelay

tracker

private java.awt.MediaTracker tracker

iCurrImage

private int iCurrImage

iLastSuccessfulImage

private int iLastSuccessfulImage

bContinue

private boolean bContinue

showThread

private java.lang.Thread showThread

backgrColor

private java.awt.Color backgrColor

foregrColor

private java.awt.Color foregrColor

textFont

private java.awt.Font textFont

imgBackgr

private java.awt.Image imgBackgr

offScrBackgr

private java.awt.Image offScrBackgr

flipNext

private java.awt.Button flipNext

flipPrev

private java.awt.Button flipPrev

flipStart

private java.awt.Button flipStart

flipEnd

private java.awt.Button flipEnd

slideStartStop

private java.awt.Button slideStartStop
Constructor Detail

anAlbum

public anAlbum()
Method Detail

init

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.
Overrides:
init in class java.applet.Applet

start

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

stop

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

destroy

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

startSlideShow

private void startSlideShow()
Start the slideshow.

stopSlideShow

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

toggleSlideShow

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

setSlideshowLabel

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

update

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

paint

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

paintImageAt

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

run

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

actionPerformed

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

prevLoaded

private void prevLoaded()
Go to the previous loaded picture

nextLoaded

private void nextLoaded()
Go to the next loaded picture

getParameterInfo

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