1 30 31 package com.jgoodies.looks.windows; 32 33 import java.beans.PropertyChangeListener ; 34 35 import javax.swing.AbstractButton ; 36 import javax.swing.JComponent ; 37 import javax.swing.plaf.ComponentUI ; 38 39 import com.jgoodies.looks.LookUtils; 40 import com.jgoodies.looks.Options; 41 import com.jgoodies.looks.common.ButtonMarginListener; 42 43 51 public final class WindowsToggleButtonUI extends com.sun.java.swing.plaf.windows.WindowsToggleButtonUI { 52 53 54 private static final WindowsToggleButtonUI INSTANCE = new WindowsToggleButtonUI(); 55 56 private PropertyChangeListener buttonMarginListener; 57 58 public static ComponentUI createUI(JComponent b) { 59 return INSTANCE; 60 } 61 62 63 66 protected void installDefaults(AbstractButton b) { 67 super.installDefaults(b); 68 LookUtils.installNarrowMargin(b, getPropertyPrefix()); 69 } 70 71 72 75 public void installListeners(AbstractButton b) { 76 super.installListeners(b); 77 if (buttonMarginListener == null) { 78 buttonMarginListener = new ButtonMarginListener(getPropertyPrefix()); 79 } 80 b.addPropertyChangeListener(Options.IS_NARROW_KEY, buttonMarginListener); 81 } 82 83 84 87 public void uninstallListeners(AbstractButton b) { 88 super.uninstallListeners(b); 89 b.removePropertyChangeListener(buttonMarginListener); 90 } 91 92 93 } | Popular Tags |