1 30 31 package com.jgoodies.looks.windows; 32 33 import java.beans.PropertyChangeEvent ; 34 import java.beans.PropertyChangeListener ; 35 36 import javax.swing.JComponent ; 37 import javax.swing.JScrollPane ; 38 import javax.swing.LookAndFeel ; 39 import javax.swing.plaf.ComponentUI ; 40 41 import com.jgoodies.looks.Options; 42 43 53 public final class WindowsScrollPaneUI extends com.sun.java.swing.plaf.windows.WindowsScrollPaneUI { 54 55 private PropertyChangeListener borderStyleChangeHandler; 56 57 public static ComponentUI createUI(JComponent b) { 58 return new WindowsScrollPaneUI(); 59 } 60 61 protected void installDefaults(JScrollPane scrollPane) { 62 super.installDefaults(scrollPane); 63 installEtchedBorder(scrollPane); 64 } 65 66 protected void installEtchedBorder(JScrollPane scrollPane) { 67 Object value = scrollPane.getClientProperty(Options.IS_ETCHED_KEY); 68 boolean hasEtchedBorder = Boolean.TRUE.equals(value); 69 LookAndFeel.installBorder(scrollPane, 70 hasEtchedBorder 71 ? "ScrollPane.etchedBorder" 72 : "ScrollPane.border"); 73 } 74 75 76 78 public void installListeners(JScrollPane scrollPane) { 79 super.installListeners(scrollPane); 80 borderStyleChangeHandler = new BorderStyleChangeHandler(); 81 scrollPane.addPropertyChangeListener(Options.IS_ETCHED_KEY, borderStyleChangeHandler); 82 } 83 84 protected void uninstallListeners(JComponent c) { 85 ((JScrollPane ) c).removePropertyChangeListener(Options.IS_ETCHED_KEY, 86 borderStyleChangeHandler); 87 super.uninstallListeners(c); 88 } 89 90 private class BorderStyleChangeHandler implements PropertyChangeListener { 91 92 public void propertyChange(PropertyChangeEvent evt) { 93 JScrollPane scrollPane = (JScrollPane ) evt.getSource(); 94 installEtchedBorder(scrollPane); 95 } 96 97 } 98 99 } | Popular Tags |