gishur.awt
Class ToolTipper

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--gishur.awt.ToolTipper
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ContainerListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Runnable, java.io.Serializable

public class ToolTipper
extends java.awt.Canvas
implements java.lang.Runnable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ContainerListener

The ToolTipper class provides Windows-like tooltips without the need of an extra window.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
 java.awt.Color backcolor
          The background color of the ToolTip.
 java.awt.Color textcolor
          The text color of the ToolTip.
 java.awt.Font tip_font
          The Font used by ToolTips.
static int TIP_SPACE
          Distance (in pixel) between Text and Tip-Border.
static byte TOOLTIP_LOWER_LEFT
          Alignment of the tooltip relative to the mouse position.
static byte TOOLTIP_LOWER_RIGHT
          Alignment of the tooltip relative to the mouse position.
static byte TOOLTIP_UPPER_LEFT
          Alignment of the tooltip relative to the mouse position.
static byte TOOLTIP_UPPER_RIGHT
          Alignment of the tooltip relative to the mouse position.
 
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
ToolTipper(java.awt.Container c)
          Constructs a new ToolTipper on the Container c.
ToolTipper(java.awt.Container c, java.applet.Applet a)
          Constructs a new ToolTipper on the Container c and connects it with the Applet a.
 
Method Summary
 void componentAdded(java.awt.event.ContainerEvent e)
          Invoked when a component has been added to the container.
 void componentRemoved(java.awt.event.ContainerEvent e)
          Invoked when a component has been removed from the container.
 byte getToolTipAlignment()
          Returns the ToolTip alignment constant (one of {TOOLTIP_LOWER_RIGHT, TOOLTIP_LOWER_LEFT,TOOLTIP_UPPER_RIGHT,TOOLTIP_UPPER_LEFT}).
 int getToolTipXDistance()
          Returns the horizontal ToolTip distance relative to the mouse position.
 int getToolTipYDistance()
          Returns the vertical ToolTip distance relative to the mouse position.
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been moved on a component (with no buttons no down).
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void paint(java.awt.Graphics g)
          Paints the ToolTip on the screen.
 void run()
          The run method for the ToolTipper-thread.
 void setShowtime(long s)
          Sets the showtime of the ToolTipper.
 void setSleeptime(long s)
          Sets the sleeptime of the ToolTipper.
 void setToolTipAlignment(byte align)
          Sets the alignment of the ToolTip.
 void setToolTipMouseDistance(int x, int y)
          Sets the distance of the ToolTip relative to the mouse position.
 long showtime()
          Returns the time to wait while showing tip (in ms).
 long sleeptime()
          Returns the time to wait until tip shows up (in ms).
 void update(java.awt.Graphics g)
          Updates the ToolTip.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOOLTIP_LOWER_RIGHT

public static final byte TOOLTIP_LOWER_RIGHT
Alignment of the tooltip relative to the mouse position.

TOOLTIP_UPPER_RIGHT

public static final byte TOOLTIP_UPPER_RIGHT
Alignment of the tooltip relative to the mouse position.

TOOLTIP_LOWER_LEFT

public static final byte TOOLTIP_LOWER_LEFT
Alignment of the tooltip relative to the mouse position.

TOOLTIP_UPPER_LEFT

public static final byte TOOLTIP_UPPER_LEFT
Alignment of the tooltip relative to the mouse position.

TIP_SPACE

public static int TIP_SPACE
Distance (in pixel) between Text and Tip-Border.

tip_font

public java.awt.Font tip_font
The Font used by ToolTips.

backcolor

public java.awt.Color backcolor
The background color of the ToolTip.

textcolor

public java.awt.Color textcolor
The text color of the ToolTip.
Constructor Detail

ToolTipper

public ToolTipper(java.awt.Container c,
                  java.applet.Applet a)
Constructs a new ToolTipper on the Container c and connects it with the Applet a.
Parameters:
c - Container to add the ToolTipper to
a - Applet for displaying StatusTips

ToolTipper

public ToolTipper(java.awt.Container c)
Constructs a new ToolTipper on the Container c.
Parameters:
c - Container to add the ToolTipper to
Method Detail

run

public void run()
The run method for the ToolTipper-thread.
Specified by:
run in interface java.lang.Runnable

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons no down).
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component.
Specified by:
mouseExited in interface java.awt.event.MouseListener

update

public void update(java.awt.Graphics g)
Updates the ToolTip.
Overrides:
update in class java.awt.Component
Parameters:
g - Graphics context

paint

public void paint(java.awt.Graphics g)
Paints the ToolTip on the screen.
Overrides:
paint in class java.awt.Canvas
Parameters:
g - Graphics context

componentAdded

public void componentAdded(java.awt.event.ContainerEvent e)
Invoked when a component has been added to the container.
Specified by:
componentAdded in interface java.awt.event.ContainerListener

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent e)
Invoked when a component has been removed from the container.
Specified by:
componentRemoved in interface java.awt.event.ContainerListener

sleeptime

public long sleeptime()
Returns the time to wait until tip shows up (in ms).

setSleeptime

public void setSleeptime(long s)
Sets the sleeptime of the ToolTipper.
Parameters:
s - the time to wait until tip shows up (in ms)

showtime

public long showtime()
Returns the time to wait while showing tip (in ms).

setShowtime

public void setShowtime(long s)
Sets the showtime of the ToolTipper.
Parameters:
s - the time to wait while showing up (in ms)

getToolTipAlignment

public byte getToolTipAlignment()
Returns the ToolTip alignment constant (one of {TOOLTIP_LOWER_RIGHT, TOOLTIP_LOWER_LEFT,TOOLTIP_UPPER_RIGHT,TOOLTIP_UPPER_LEFT}).
Returns:
alignment of the ToolTip

setToolTipAlignment

public void setToolTipAlignment(byte align)
Sets the alignment of the ToolTip.
Parameters:
alignment - constant (one of {TOOLTIP_LOWER_RIGHT, TOOLTIP_LOWER_LEFT,TOOLTIP_UPPER_RIGHT,TOOLTIP_UPPER_LEFT})

getToolTipXDistance

public int getToolTipXDistance()
Returns the horizontal ToolTip distance relative to the mouse position.
Returns:
the horizontal ToolTip distance relative to the mouse position.

getToolTipYDistance

public int getToolTipYDistance()
Returns the vertical ToolTip distance relative to the mouse position.
Returns:
the vertical ToolTip distance relative to the mouse position.

setToolTipMouseDistance

public void setToolTipMouseDistance(int x,
                                    int y)
Sets the distance of the ToolTip relative to the mouse position.
Parameters:
x - horizontal distance
y - vertical distance

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.
Specified by:
mouseReleased in interface java.awt.event.MouseListener