GUI Commands 2.0 has arrived! Find out what's new and improved.
Hovering

Since it's such a common practice to provide user feedback when the mouse hovers over a button or menu, a simple HoverListeneris available to facilitate this task.  The HoverListener interface defines two methods that notify when the mouse enters and leaves a command generated button, menu or hyperlink.

HoverListeners can be registered with individual commands or with the CommandManager.  Listeners added to a command are only notified of hover events over that specific command whereas listeners added to the CommandManager are notified of all hover events.

This is a typical case where the long-description attribute of faces can be put to good use as the following example shows.

Example

   CommandManager.defaultInstance().addHoverListener(new HoverListener() 
   {
      public void hoverStarted(HoverEvent e)
      {
         String text = e.getFace().getLongDescription();
         if (text == null)
            text = e.getFace().getDescription();
         statusBar.setText(text);
      }

      public void hoverEnded(HoverEvent e)
      {
         statusBar.setText("");
      }
   });