1 19 package org.netbeans.modules.welcome.content; 20 21 import java.awt.event.ActionEvent ; 22 import java.awt.event.MouseEvent ; 23 import javax.swing.Action ; 24 import javax.swing.Icon ; 25 import org.openide.awt.StatusDisplayer; 26 27 public class ActionButton extends LinkButton { 28 29 private Action action; 30 private String urlString; 31 32 public ActionButton( Action a, boolean showBullet, String urlString ) { 33 super( a.getValue( Action.NAME ).toString(), showBullet ); 34 this.action = a; 35 this.urlString = urlString; 36 Object icon = a.getValue( Action.SMALL_ICON ); 37 if( null != icon && icon instanceof Icon ) 38 setIcon( (Icon )icon ); 39 Object tooltip = a.getValue( Action.SHORT_DESCRIPTION ); 40 if( null != tooltip ) 41 setToolTipText( tooltip.toString() ); 42 } 43 44 public void actionPerformed(ActionEvent e) { 45 if( null != action ) { 46 action.actionPerformed( e ); 47 } 48 } 49 50 protected void onMouseExited(MouseEvent e) { 51 if( null != urlString ) { 52 StatusDisplayer.getDefault().setStatusText( "" ); } 54 } 55 56 protected void onMouseEntered(MouseEvent e) { 57 if( null != urlString ) { 58 StatusDisplayer.getDefault().setStatusText( urlString ); 59 } 60 } 61 62 private static final long serialVersionUID = 1L; 63 } 64 | Popular Tags |