hades.utils
Class DidYouKnowFrame

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byhades.utils.DidYouKnowFrame
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, java.io.Serializable

public class DidYouKnowFrame
extends java.awt.Frame
implements java.awt.event.ActionListener, java.awt.event.ItemListener

frame to display Windows-style "did you know" tips.

DidYouKnowFrame - a class to display hints and tips in the style of MS-Office and Windows-97 'tips' windows. The individual tips are read from a file once the window is first displayed. While all tips are loaded initially, only a randomly selected tip is displayed. On each click of 'next' the successor is displayed, to allow for tips that rely on each other.

The file with the tips is specified via the Java 1.1 resource mechanism, to allow for easy use of DidYouKnowFrame in both applets and applications. Call 'setResourceName())' to specify the file location at run time.

The file format for the 'tips file' is very simple. A blank line marks the end of each entry. A none blank line and its immediate successor describe one tip.

The Windows'95 style icon is loaded from a Java resource called '/hades/gui/images/didyouknow.gif'.

See Also:
Serialized Form

Nested Class Summary
(package private)  class DidYouKnowFrame.WindowCloser
           
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Checkbox againCheckbox
           
protected  java.awt.Font buttonFont
           
protected  java.awt.Button closeButton
           
protected  ImageCanvas iconCanvas
           
protected  int index
           
protected  java.awt.Button nextButton
           
protected  java.awt.Button prevButton
           
protected  java.lang.String resourcename
           
protected  java.awt.TextArea textArea
           
protected  java.awt.Font textAreaFont
           
protected  java.util.Vector tips
           
(package private) static java.lang.String tipsFileName
           
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
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
DidYouKnowFrame()
          This default constructor tries to load a tips file for HADES from the default resource, '/hades/doc/help/TipOfTheDay.txt'.
DidYouKnowFrame(java.lang.String resourcename)
          Construct and display a DidYouKnowFrame, where the tips are read from the Java 1.1 resource 'resourcename', e.g.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          react to the 'close' and 'next' Buttons.
 void doClose()
          close our window and free the String array tips[] with the tips to reclaim the memory.
 void getDefaultFonts()
           
 java.lang.String getIconName()
           
 void itemStateChanged(java.awt.event.ItemEvent e)
          react to the 'show again' Checkbox.
static void main(java.lang.String[] argv)
          simple self test: display the demo messeges from '/hades/doc/tips.txt'
 void msg(java.lang.String s)
           
 java.util.Vector parse(java.lang.String resourcename)
           
 void selectTip(int index)
          select and display the tip with index 'index' from the Vector of all tips.
 void showNextTip()
          try to display the next hint/tip from the tips[] array in sequential order.
 void showPreviousTip()
           
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, 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, addImpl, 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, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, 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
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

tipsFileName

static final java.lang.String tipsFileName
See Also:
Constant Field Values

resourcename

protected java.lang.String resourcename

tips

protected java.util.Vector tips

index

protected int index

iconCanvas

protected ImageCanvas iconCanvas

nextButton

protected java.awt.Button nextButton

prevButton

protected java.awt.Button prevButton

closeButton

protected java.awt.Button closeButton

againCheckbox

protected java.awt.Checkbox againCheckbox

textArea

protected java.awt.TextArea textArea

buttonFont

protected java.awt.Font buttonFont

textAreaFont

protected java.awt.Font textAreaFont
Constructor Detail

DidYouKnowFrame

public DidYouKnowFrame()
This default constructor tries to load a tips file for HADES from the default resource, '/hades/doc/help/TipOfTheDay.txt'.


DidYouKnowFrame

public DidYouKnowFrame(java.lang.String resourcename)
Construct and display a DidYouKnowFrame, where the tips are read from the Java 1.1 resource 'resourcename', e.g. '/mypackage/mytips.txt'.

Method Detail

getDefaultFonts

public void getDefaultFonts()

getIconName

public java.lang.String getIconName()

parse

public java.util.Vector parse(java.lang.String resourcename)

selectTip

public void selectTip(int index)
select and display the tip with index 'index' from the Vector of all tips. Indices out of range are silently ignored and replaced with a valid index.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
react to the 'close' and 'next' Buttons.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

doClose

public void doClose()
close our window and free the String array tips[] with the tips to reclaim the memory.


showNextTip

public void showNextTip()
try to display the next hint/tip from the tips[] array in sequential order. If no tips remain at the end of the array, we wrap around to the first tip again.

The next tip is chosen sequential instead of at random to allow for tips that build on each other.


showPreviousTip

public void showPreviousTip()

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
react to the 'show again' Checkbox. Currently, we ignore the user's request not to annoy him again...

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

msg

public void msg(java.lang.String s)

main

public static void main(java.lang.String[] argv)
simple self test: display the demo messeges from '/hades/doc/tips.txt'