swingx
Version 2005-08-19

org.jdesktop.swingx
Class MouseMessagingHandler

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by org.jdesktop.swingx.MouseMessagingHandler
All Implemented Interfaces:
MouseListener, EventListener

public class MouseMessagingHandler
extends MouseAdapter

Mouse handler which listens to mouse entered events on action based components and send the value of the LONG_DESCRIPTION as a transient message to the MessageListener and the listeners registered to the MessageSource.

Components can be registered using the register methods. For example, to register all the components of a toolbar and all menu items in a menu bar to send mouse over messages to a status bar:

    handler = new MouseMessagingHandler(this, statusBar);
    if (toolBar != null) {
        handler.registerListeners(toolBar.getComponents());
    }
    if (menuBar != null) {
      handler.registerListeners(menuBar.getSubElements());
    }
 


Constructor Summary
MouseMessagingHandler(Object source, MessageListener messageListener)
           
MouseMessagingHandler(Object source, MessageSource messageSource)
           
 
Method Summary
 void mouseEntered(MouseEvent evt)
          Takes the LONG_DESCRIPTION of the Action based components and sends them to the Status bar
 void mouseExited(MouseEvent evt)
           
 void registerListeners(Component[] components)
          Helper method to register all components with this message handler
 void registerListeners(MenuElement[] elements)
          Helper method to recursively register all MenuElements with this messaging handler.
 void setMessageListener(MessageListener listener)
           
 void setMessageSource(MessageSource source)
           
 void setSource(Object source)
          Set the source object of the MessageEvents.
 void unregisterListeners(Component[] components)
           
 void unregisterListeners(MenuElement[] elements)
           
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MouseMessagingHandler

public MouseMessagingHandler(Object source,
                             MessageSource messageSource)
Parameters:
source - the source of the MesageEvents
messageSource - messages will be sent to these listeners

MouseMessagingHandler

public MouseMessagingHandler(Object source,
                             MessageListener messageListener)
Parameters:
source - the source of the MesageEvents
messageListener - messages will be sent to this listener
Method Detail

setSource

public void setSource(Object source)
Set the source object of the MessageEvents.


setMessageSource

public void setMessageSource(MessageSource source)

setMessageListener

public void setMessageListener(MessageListener listener)

mouseExited

public void mouseExited(MouseEvent evt)
Specified by:
mouseExited in interface MouseListener
Overrides:
mouseExited in class MouseAdapter

mouseEntered

public void mouseEntered(MouseEvent evt)
Takes the LONG_DESCRIPTION of the Action based components and sends them to the Status bar

Specified by:
mouseEntered in interface MouseListener
Overrides:
mouseEntered in class MouseAdapter

registerListeners

public void registerListeners(MenuElement[] elements)
Helper method to recursively register all MenuElements with this messaging handler.


unregisterListeners

public void unregisterListeners(MenuElement[] elements)

registerListeners

public void registerListeners(Component[] components)
Helper method to register all components with this message handler


unregisterListeners

public void unregisterListeners(Component[] components)

swingx
Version 2005-08-19