1 42 43 package org.jfree.ui; 44 45 import java.awt.event.MouseAdapter ; 46 import java.awt.event.MouseEvent ; 47 48 import javax.swing.AbstractButton ; 49 50 56 public final class FloatingButtonEnabler extends MouseAdapter { 57 58 59 private static FloatingButtonEnabler singleton; 60 61 64 private FloatingButtonEnabler() { 65 } 67 68 73 public static FloatingButtonEnabler getInstance() { 74 if (singleton == null) { 75 singleton = new FloatingButtonEnabler(); 76 } 77 return singleton; 78 } 79 80 85 public void addButton(final AbstractButton button) { 86 button.addMouseListener(this); 87 button.setBorderPainted(false); 88 } 89 90 95 public void removeButton(final AbstractButton button) { 96 button.addMouseListener(this); 97 button.setBorderPainted(true); 98 } 99 100 105 public void mouseEntered(final MouseEvent e) { 106 if (e.getSource() instanceof AbstractButton ) { 107 final AbstractButton button = (AbstractButton ) e.getSource(); 108 if (button.isEnabled()) { 109 button.setBorderPainted(true); 110 } 111 } 112 } 113 114 119 public void mouseExited(final MouseEvent e) { 120 if (e.getSource() instanceof AbstractButton ) { 121 final AbstractButton button = (AbstractButton ) e.getSource(); 122 button.setBorderPainted(false); 123 if (button.getParent() != null) 124 { 125 button.getParent().repaint(); 128 } 129 } 130 } 131 132 } 133 | Popular Tags |