1 22 23 package org.gjt.sp.jedit.gui; 24 25 import javax.swing.*; 27 import java.awt.event.*; 28 import java.awt.*; 29 import org.gjt.sp.jedit.*; 30 32 public class EnhancedButton extends RolloverButton 33 { 34 public EnhancedButton(Icon icon, String toolTip, String action, 36 ActionContext context) 37 { 38 super(icon); 39 40 this.action = action; 41 42 if(action != null) 43 { 44 setEnabled(true); 45 addActionListener(new EditAction.Wrapper(context,action)); 46 addMouseListener(new MouseHandler()); 47 } 48 else 49 setEnabled(false); 50 51 setToolTipText(toolTip); 52 } 54 public boolean isFocusTraversable() 56 { 57 return false; 58 } 60 private String action; 62 64 class MouseHandler extends MouseAdapter 66 { 67 boolean msgSet = false; 68 69 public void mouseReleased(MouseEvent evt) 70 { 71 if(msgSet) 72 { 73 GUIUtilities.getView((Component)evt.getSource()) 74 .getStatus().setMessage(null); 75 msgSet = false; 76 } 77 } 78 79 public void mouseEntered(MouseEvent evt) 80 { 81 String msg = jEdit.getProperty(action + ".mouse-over"); 82 if(msg != null) 83 { 84 GUIUtilities.getView((Component)evt.getSource()) 85 .getStatus().setMessage(msg); 86 msgSet = true; 87 } 88 } 89 90 public void mouseExited(MouseEvent evt) 91 { 92 if(msgSet) 93 { 94 GUIUtilities.getView((Component)evt.getSource()) 95 .getStatus().setMessage(null); 96 msgSet = false; 97 } 98 } 99 } } 101 | Popular Tags |