wt.help
Class ToolTips

java.lang.Object
  extended bywt.help.ToolTips
All Implemented Interfaces:
Runnable

public class ToolTips
extends Object
implements Runnable

An instance of class ToolTips is used to manage the tool tips for a help context. An instance of ToolTips manages a series of ToolTipListeners which listen to awt components and and display a delayed tool tip when the mouse entered event happens to the awt component.

Supported API: true
Extendable: false


Nested Class Summary
(package private)  class ToolTips.ToolTipDisplay
          Class of object used to display tool tip in window.
(package private)  class ToolTips.ToolTipListener
          Inner class whos instances listen to a component for tool tip events.
 
Field Summary
protected  Hashtable componentListeners
           
protected  Container container
          The component container in which the tool tips will be displayed.
static long DELAY_PRECISION
          Since clock precision is about 15 milliseconds.
protected  Thread delayThread
           
protected  Object delayThreadLock
           
protected  long delayThreadWaitTime
           
protected  FontMetrics fontMetrics
           
static long MAXIMUM_DELAY
          Maximum tool tip delay is 20 seconds.
static long MININUM_DELAY
          Mininum tool tip delay is 100 milliseconds.
private static String RESOURCE
           
protected static int TIP_DISPLAY_HEIGHT_PAD
           
protected static int TIP_DISPLAY_INSET
          Parameters for displaying the tool tips.
protected static int TIP_DISPLAY_WIDTH_PAD
           
protected  int TIP_DISPLAY_Y_OFFSET
           
protected  Color toolTipBackground
          The background color for tool tip display.
protected  long toolTipDelay
          The delay following the mouse entered event, before the tip displays.
protected  ToolTips.ToolTipDisplay toolTipDisplay
           
protected  Font toolTipFont
          The font for tool tip display.
protected  Color toolTipForeground
          The foreground color for tool tip display.
 
Constructor Summary
ToolTips(Container container)
          Construct a ToolTips manager and pass in the container.
 
Method Summary
 void addComponentToolTip(Component component, String tipText)
          Add the component and the tip text.
protected  Point adjustLocation(Dimension outerSize, Dimension innerSize, Point point)
           
 Container getContainer()
          Get the container for the tool tips.
 void hideTip()
          Hide the currently displayed tool tip.
 void removeComponentToolTip(Component component)
          Remove the component.
 void run()
          This method runs when delayThread.start() is invoked.
protected  void setContainer(Container newValue)
          Set the container for the tool tips.
 void setToolTipBackground(Color newValue)
          Set the background color for tool tip display.
 void setToolTipDelay(long milliSeconds)
          Set the amount of time in milliseconds a tool tip display should delay after the mouse rests on a component.
 void setToolTipFont(Font newValue)
          Set the font for tool tip display.
 void setToolTipForeground(Color newValue)
          Set the foreground color for tool tip display.
protected  void showTip(String tip, Point point)
          Show the tool tip at the specified point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

container

protected Container container
The component container in which the tool tips will be displayed.


toolTipFont

protected Font toolTipFont
The font for tool tip display.


toolTipBackground

protected Color toolTipBackground
The background color for tool tip display.


toolTipForeground

protected Color toolTipForeground
The foreground color for tool tip display.


toolTipDelay

protected long toolTipDelay
The delay following the mouse entered event, before the tip displays.


MININUM_DELAY

public static final long MININUM_DELAY
Mininum tool tip delay is 100 milliseconds.

See Also:
Constant Field Values

MAXIMUM_DELAY

public static final long MAXIMUM_DELAY
Maximum tool tip delay is 20 seconds.

See Also:
Constant Field Values

DELAY_PRECISION

public static final long DELAY_PRECISION
Since clock precision is about 15 milliseconds.

See Also:
Constant Field Values

TIP_DISPLAY_INSET

protected static final int TIP_DISPLAY_INSET
Parameters for displaying the tool tips.

See Also:
Constant Field Values

TIP_DISPLAY_WIDTH_PAD

protected static final int TIP_DISPLAY_WIDTH_PAD
See Also:
Constant Field Values

TIP_DISPLAY_HEIGHT_PAD

protected static final int TIP_DISPLAY_HEIGHT_PAD
See Also:
Constant Field Values

TIP_DISPLAY_Y_OFFSET

protected int TIP_DISPLAY_Y_OFFSET

toolTipDisplay

protected ToolTips.ToolTipDisplay toolTipDisplay

fontMetrics

protected FontMetrics fontMetrics

componentListeners

protected Hashtable componentListeners

delayThread

protected Thread delayThread

delayThreadWaitTime

protected long delayThreadWaitTime

delayThreadLock

protected Object delayThreadLock
Constructor Detail

ToolTips

public ToolTips(Container container)
         throws PropertyVetoException
Construct a ToolTips manager and pass in the container.

Parameters:
container - the container for the tool tip context.
Throws:
PropertyVetoException - if the container is invalid.
Method Detail

getContainer

public Container getContainer()
Get the container for the tool tips.

Returns:
the tool tips target container.

setContainer

protected void setContainer(Container newValue)
                     throws PropertyVetoException
Set the container for the tool tips. Currently is protected as this implementation does'nt support changing the container.

Parameters:
newValue - the new container.
Throws:
PropertyVetoException - if the new container is invalid.

setToolTipFont

public void setToolTipFont(Font newValue)
                    throws PropertyVetoException
Set the font for tool tip display.

Parameters:
newValue - the new font.
Throws:
PropertyVetoException - if the new font is invalid.

setToolTipBackground

public void setToolTipBackground(Color newValue)
                          throws PropertyVetoException
Set the background color for tool tip display.

Parameters:
newValue - the new background color.
Throws:
PropertyVetoException - if the new value is invalid.

setToolTipForeground

public void setToolTipForeground(Color newValue)
                          throws PropertyVetoException
Set the foreground color for tool tip display.

Parameters:
newValue - the new value of the color.
Throws:
PropertyVetoException - if the new color is invalid.

setToolTipDelay

public void setToolTipDelay(long milliSeconds)
                     throws IllegalArgumentException
Set the amount of time in milliseconds a tool tip display should delay after the mouse rests on a component.

Throws:
IllegalArgumentException - thrown when param milliseconds is invalid.

addComponentToolTip

public void addComponentToolTip(Component component,
                                String tipText)
Add the component and the tip text. If the component is already registered with this ToolTips it will be re-registered with the new tip.

Parameters:
component - the component to listen to.
tipText - the text of the tool tip.

removeComponentToolTip

public void removeComponentToolTip(Component component)
Remove the component.

Parameters:
component - the component to remove from the list of listeners.

showTip

protected void showTip(String tip,
                       Point point)
Show the tool tip at the specified point.

Parameters:
tip - the tip text to be displayed.
point - the display point.

hideTip

public void hideTip()
Hide the currently displayed tool tip. Stop any pending display.


run

public void run()
This method runs when delayThread.start() is invoked. This operation should not be called directly, it is invoked by operation showTip.

Specified by:
run in interface Runnable

adjustLocation

protected Point adjustLocation(Dimension outerSize,
                               Dimension innerSize,
                               Point point)