View RSS Feed

Java Swing

Sending a Description of an Action to a Status Bar

Rate this Entry
by , 04-26-2012 at 08:22 PM (544 Views)
Requested feature that is more common is that architecture which supports the content messages sending to status bar, when mouse is present at toolbar buttons or menu items. Support will be provided by the architecture of current action which behaves elegantly.
When and addition of action is done to a container like JMenu or JToolBar, component which got added to container, is returned. MouseAdapterís shared instance is added, to returned components. When at component the mouse is moved, moused entred event would be sent to mouse adapter. In this way mouseEntered() method present at the adapter would obtain the Action.LONG_DESCRIPTION value.


Java Code:
  
 public void mouseEntered(MouseEvent evt)  {

       if (evt.getSource() instanceof AbstractButton)  {

           AbstractButton button = (AbstractButton)evt.getSource();

           // getAction is new in JDK 1.3

           Action action = button.getAction(); 


           if (action != null)  {

               Object message = action.getValue(Action.LONG_DESCRIPTION);

               label.setText(message.toString());

           }

       }

   }

Submit "Sending a Description of an Action to a Status Bar" to Facebook Submit "Sending a Description of an Action to a Status Bar" to Digg Submit "Sending a Description of an Action to a Status Bar" to del.icio.us Submit "Sending a Description of an Action to a Status Bar" to StumbleUpon Submit "Sending a Description of an Action to a Status Bar" to Google

Tags: status bar Add / Edit Tags
Categories
Actions

Comments