PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/org/gjt/sp/jedit/gui/EnhancedButton.java

#
Java | 84 lines | 46 code | 10 blank | 28 comment | 4 complexity | d70afcabefc90643e41e14344111dee4 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * EnhancedButton.java - Tool bar button
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 1999, 2001, 2002 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.gui;
  23. //{{{ Imports
  24. import javax.swing.*;
  25. import java.awt.event.*;
  26. import java.awt.*;
  27. import org.gjt.sp.jedit.textarea.JEditTextArea;
  28. import org.gjt.sp.jedit.EditAction;
  29. import org.gjt.sp.jedit.GUIUtilities;
  30. //}}}
  31. public class EnhancedButton extends RolloverButton
  32. {
  33. //{{{ EnhancedButton constructor
  34. public EnhancedButton(Icon icon, String toolTip, EditAction action)
  35. {
  36. super(icon);
  37. this.action = action;
  38. if(action != null)
  39. {
  40. setEnabled(true);
  41. addActionListener(new EditAction.Wrapper(action));
  42. addMouseListener(new MouseHandler());
  43. }
  44. else
  45. setEnabled(false);
  46. setToolTipText(toolTip);
  47. } //}}}
  48. //{{{ isFocusTraversable() method
  49. public boolean isFocusTraversable()
  50. {
  51. return false;
  52. } //}}}
  53. //{{{ Private members
  54. private EditAction action;
  55. //}}}
  56. //{{{ MouseHandler class
  57. class MouseHandler extends MouseAdapter
  58. {
  59. public void mouseEntered(MouseEvent evt)
  60. {
  61. String msg = action.getMouseOverText();
  62. if(msg != null)
  63. {
  64. GUIUtilities.getView((Component)evt.getSource())
  65. .getStatus().setMessage(msg);
  66. }
  67. }
  68. public void mouseExited(MouseEvent evt)
  69. {
  70. GUIUtilities.getView((Component)evt.getSource())
  71. .getStatus().setMessage(null);
  72. }
  73. } //}}}
  74. }