com.sygem.swing.jtipoftheday
Class JTipOfTheDay

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byjavax.swing.JDialog
                      extended bycom.sygem.swing.jtipoftheday.JTipOfTheDay
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class JTipOfTheDay
extends javax.swing.JDialog
implements java.io.Serializable

The JTipOfTheDay component provides an easy way to get startup tips into your application.

A simple dialog is presented to the user, which is highly configurable. It offers the ability to skip to the previous or next tip, and set whether or not the tips should be displayed on startup. A counter showing which tip is currently showing, and the total number of tips is also displayed.

Title: JTipOfTheDay
Description: A Swing component for displaying a Tip on startup
Copyright: Copyright (c) 2004
Company: SyGem Software

Version:
1.0b
See Also:
Serialized Form

Field Summary
static int ICON_MIDDLE
          Specifies that any icon should be located in the middle of the icon panel
static int ICON_THIRD
          Specifies that any icon should be located a third of the way down from the top of the icon panel
static int ICON_TOP
          Specifies that any icon should be located at the top of the icon panel
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JTipOfTheDay(javax.swing.JFrame parent)
          Basic constructor, assumes the tips file will be called "tips.txt", and located in the current working directory.
JTipOfTheDay(javax.swing.JFrame parent, java.lang.String file)
          The version of the JTipOfTheDay constructor allows you to specify the location of the tips file.
 
Method Summary
 void addIconImage(java.awt.Image i)
          Adds a new image to be displayed on the icon panel.
 void addTipChangeListener(TipChangeListener tcl)
          Adds a TipChangeListener.
 void addTipShowListener(TipShowListener tsl)
          Adds a TipShowListener.
 void displayNextIconImage()
          Changes the display on the icon panel to the next available icon.
 java.awt.Font getHeaderFont()
          Returns the font used to render the header text
 java.lang.String getHeaderTitle()
          Returns the current header text value.
 BackgroundRenderer getIconPanelRenderer()
          Returns the current renderer assigned to the Icon Panel.
 int getIconPanelWidth()
          Returns the width of the icon panel.
 int getIconPosition()
          Gets the icon position.
 java.awt.Font getTipTextFont()
          Returns the font used for displaying the tips
 int getWindowHeight()
          Returns the height of the tip window.
 java.lang.String getWindowTitle()
          Returns the title of the tip window
 int getWindowWidth()
          Returns the width of the tip window.
 boolean isAntiAliased()
          Returns whether or not the tips dialog is drawn using anti-aliasing.
 boolean isPreviousButtonEnabled()
          Returns whether or not the "Previous Tip" button has been enabled.
 boolean isScrollPaneVisible()
          Returns TRUE if the tips panel is set to display a scrollbar for long tips.
 boolean isShowOnStartup()
          Returns whether or not the tips dialog should be shown on startup.
 void setAntiAliased(boolean antiAliased)
          Sets the tips dialog to be drawn using anti-aliasing, for smoother text and graphics.
 void setHeaderFont(java.awt.Font headerFont)
          Sets the font used to render the header text
 void setHeaderTitle(java.lang.String headerTitle)
          Sets the value of the header text
 void setIconPanelRenderer(BackgroundRenderer r)
          Sets the renderer for the Icon Panel (left panel).
 void setIconPanelWidth(int w)
          Sets the width of the icon panel.
 void setIconPosition(int iconPosition)
          Sets the position of images in the icon panel.
 void setInitialTipIndex(int i)
          Sets the index of the tip to show when the dialog is displayed.
 void setPreviousButtonEnabled(boolean previousButtonEnabled)
          Sets the "Previous Tip" button to be enabled/disabled.
 void setScrollPaneVisible(boolean scrollPaneVisible)
          Sets the tips panel to display scrollbars for long tips.
 void setShowOnStartup(boolean showOnStartup)
          Sets the value used by the "Show Tips on Startup" checkbox.
 void setTipTextFont(java.awt.Font f)
          Sets the font used for displaying the tips.
 void setWindowHeight(int windowHeight)
          Sets the height of the tip window.
 void setWindowTitle(java.lang.String windowTitle)
          Sets the title of the tip window
 void setWindowWidth(int windowWidth)
          Sets the width of the tip window.
 void showTips()
          Displays the Tip Of The Day dialog.
 
Methods inherited from class javax.swing.JDialog
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, 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, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ICON_MIDDLE

public static final int ICON_MIDDLE
Specifies that any icon should be located in the middle of the icon panel

See Also:
Constant Field Values

ICON_THIRD

public static final int ICON_THIRD
Specifies that any icon should be located a third of the way down from the top of the icon panel

See Also:
Constant Field Values

ICON_TOP

public static final int ICON_TOP
Specifies that any icon should be located at the top of the icon panel

See Also:
Constant Field Values
Constructor Detail

JTipOfTheDay

public JTipOfTheDay(javax.swing.JFrame parent)
Basic constructor, assumes the tips file will be called "tips.txt", and located in the current working directory.

Parameters:
parent - The parent frame

JTipOfTheDay

public JTipOfTheDay(javax.swing.JFrame parent,
                    java.lang.String file)
The version of the JTipOfTheDay constructor allows you to specify the location of the tips file.

Parameters:
parent - The parent frame
file - The location of the tips file
Method Detail

addIconImage

public void addIconImage(java.awt.Image i)
Adds a new image to be displayed on the icon panel. These images can be animated through use of the displayNextIconImage() method.

Parameters:
i - An Image
See Also:
displayNextIconImage()

addTipChangeListener

public void addTipChangeListener(TipChangeListener tcl)
Adds a TipChangeListener. These will be notified when either the "Previous" or "Next" buttons are pressed.

Parameters:
tcl - A TipChangeListener object

addTipShowListener

public void addTipShowListener(TipShowListener tsl)
Adds a TipShowListener. These will be notified when the user changes the "Show Tips on Startup" option.

Parameters:
tsl - A TipShowListener object

displayNextIconImage

public void displayNextIconImage()
Changes the display on the icon panel to the next available icon. The display will automatically wrap around to the first icon once the last registered icon has been displayed.


getHeaderFont

public java.awt.Font getHeaderFont()
Returns the font used to render the header text

Returns:
A Font

getHeaderTitle

public java.lang.String getHeaderTitle()
Returns the current header text value.

Returns:
The header text

getIconPanelRenderer

public BackgroundRenderer getIconPanelRenderer()
Returns the current renderer assigned to the Icon Panel. Will return null if no renderer has been specified.

Returns:
The icon panel BackgroundRenderer

getIconPanelWidth

public int getIconPanelWidth()
Returns the width of the icon panel.

Returns:
The width of the icon panel

getIconPosition

public int getIconPosition()
Gets the icon position. Will be one of the ICON constants defined in this class.

Returns:
The icon position

getTipTextFont

public java.awt.Font getTipTextFont()
Returns the font used for displaying the tips

Returns:
The current tip text font

getWindowHeight

public int getWindowHeight()
Returns the height of the tip window.

Returns:
The height of the tip window

getWindowTitle

public java.lang.String getWindowTitle()
Returns the title of the tip window

Returns:
The title of the tip window

getWindowWidth

public int getWindowWidth()
Returns the width of the tip window.

Returns:
The width of the tip window

isAntiAliased

public boolean isAntiAliased()
Returns whether or not the tips dialog is drawn using anti-aliasing.

Returns:
a boolean value

isPreviousButtonEnabled

public boolean isPreviousButtonEnabled()
Returns whether or not the "Previous Tip" button has been enabled.

Returns:
boolean

isScrollPaneVisible

public boolean isScrollPaneVisible()
Returns TRUE if the tips panel is set to display a scrollbar for long tips.

Returns:
boolean

isShowOnStartup

public boolean isShowOnStartup()
Returns whether or not the tips dialog should be shown on startup. After the tips dialog has been closed, this will represent the value of the "Show Tips on Startup" checkbox.

Returns:
boolean

setAntiAliased

public void setAntiAliased(boolean antiAliased)
Sets the tips dialog to be drawn using anti-aliasing, for smoother text and graphics.

Parameters:
antiAliased - boolean

setHeaderFont

public void setHeaderFont(java.awt.Font headerFont)
Sets the font used to render the header text

Parameters:
headerFont - A Font

setHeaderTitle

public void setHeaderTitle(java.lang.String headerTitle)
Sets the value of the header text

Parameters:
headerTitle - String

setIconPanelRenderer

public void setIconPanelRenderer(BackgroundRenderer r)
Sets the renderer for the Icon Panel (left panel). These renderers are from our FREE renderers library - click here for more details

Parameters:
r - A BackgroundRenderer object

setIconPanelWidth

public void setIconPanelWidth(int w)
Sets the width of the icon panel.

Parameters:
w - The new width for the icon panel

setIconPosition

public void setIconPosition(int iconPosition)
Sets the position of images in the icon panel. Should be one of the ICON constants defined in this class.

Parameters:
iconPosition - The position for images in the icon panel

setInitialTipIndex

public void setInitialTipIndex(int i)
Sets the index of the tip to show when the dialog is displayed. The first tip is at index 1.

Parameters:
i - The tip to show

setPreviousButtonEnabled

public void setPreviousButtonEnabled(boolean previousButtonEnabled)
Sets the "Previous Tip" button to be enabled/disabled.

Parameters:
previousButtonEnabled - boolean

setScrollPaneVisible

public void setScrollPaneVisible(boolean scrollPaneVisible)
Sets the tips panel to display scrollbars for long tips.

Parameters:
scrollPaneVisible - boolean

setShowOnStartup

public void setShowOnStartup(boolean showOnStartup)
Sets the value used by the "Show Tips on Startup" checkbox.

Parameters:
showOnStartup - boolean

setTipTextFont

public void setTipTextFont(java.awt.Font f)
Sets the font used for displaying the tips.

Parameters:
f - A font

setWindowHeight

public void setWindowHeight(int windowHeight)
Sets the height of the tip window.

Parameters:
windowHeight - The new height of the tip window

setWindowTitle

public void setWindowTitle(java.lang.String windowTitle)
Sets the title of the tip window

Parameters:
windowTitle - The new title of the tip window

setWindowWidth

public void setWindowWidth(int windowWidth)
Sets the width of the tip window.

Parameters:
windowWidth - The new width of the tip window

showTips

public void showTips()
Displays the Tip Of The Day dialog. Should only be called once all of the configuration has been done.



Copyright © 2004 SyGem Software. All Rights Reserved.