org.xnap.commons.gui.util
Class WhatsThis

java.lang.Object
  extended by org.xnap.commons.gui.util.WhatsThis

public class WhatsThis
extends Object

Static helper class, that allows to enrich components with What's This help.

See setText(JComponent, String) and enterWhatsThisMode().

Author:
Felix Berger
See Also:
WhatsThisAction

Constructor Summary
WhatsThis()
           
 
Method Summary
static void enterWhatsThisMode()
          Enters What's This mode.
static void exitWhatsThisMode()
          Exits What's this mode.
static String getText(Component c, boolean searchParents)
          Retrieves the what's this text for the component.
static void removeText(JComponent c)
          Removes the what's this text for the component
static void setText(JComponent c, String text)
          Sets the what's this text for the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WhatsThis

public WhatsThis()
Method Detail

setText

public static void setText(JComponent c,
                           String text)
Sets the what's this text for the component.

Parameters:
c - the component
text - the text that should be displayed in the what's this popup for this component

removeText

public static void removeText(JComponent c)
Removes the what's this text for the component

Parameters:
c - the component

getText

public static String getText(Component c,
                             boolean searchParents)
Retrieves the what's this text for the component. If searchParents is true their text is retrieved as fallback.

Parameters:
c - the component
searchParents - if true the component hierarchy is searched
Returns:
the text; null, if no what's this text has been set

enterWhatsThisMode

public static void enterWhatsThisMode()
Enters What's This mode.

A global mouse listener is added to the awt event queue looking for mouse movement and mouse clicks.

A special cursor is displayed for components that provide a What's this help text, another special cursor is displayed for components that don't.

The mode is exited automatically after the first mouse button click on any component. If the component in question has a What's this help text, the text is displayed in a popup.


exitWhatsThisMode

public static void exitWhatsThisMode()
Exits What's this mode.

See enterWhatsThisMode(). The global mouse listener is deregistered and the original cursors for all components are restored.



Copyright © 2004-2007 XNap Commons Team. All Rights Reserved.