< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/metal/MetalScrollPaneUI.java

Print this page




  28 import javax.swing.*;
  29 import javax.swing.event.*;
  30 import javax.swing.border.*;
  31 import javax.swing.plaf.*;
  32 import javax.swing.plaf.basic.*;
  33 
  34 import java.awt.*;
  35 import java.beans.*;
  36 import java.awt.event.*;
  37 
  38 
  39 /**
  40  * A Metal L&amp;F implementation of ScrollPaneUI.
  41  * <p>
  42  * <strong>Warning:</strong>
  43  * Serialized objects of this class will not be compatible with
  44  * future Swing releases. The current serialization support is
  45  * appropriate for short term storage or RMI between applications running
  46  * the same version of Swing.  As of 1.4, support for long term storage
  47  * of all JavaBeans&trade;
  48  * has been added to the <code>java.beans</code> package.
  49  * Please see {@link java.beans.XMLEncoder}.
  50  *
  51  * @author Steve Wilson
  52  */
  53 @SuppressWarnings("serial") // Same-version serialization only
  54 public class MetalScrollPaneUI extends BasicScrollPaneUI
  55 {
  56 
  57     private PropertyChangeListener scrollBarSwapListener;
  58 
  59     /**
  60      * Constructs a new {@code MetalScrollPaneUI}.
  61      *
  62      * @param x a component
  63      * @return a new {@code MetalScrollPaneUI}
  64      */
  65     public static ComponentUI createUI(JComponent x) {
  66         return new MetalScrollPaneUI();
  67     }
  68 


  97     /**
  98      * {@inheritDoc}
  99      */
 100     protected void uninstallListeners(JComponent c) {
 101         super.uninstallListeners(c);
 102         c.removePropertyChangeListener(scrollBarSwapListener);
 103     }
 104 
 105     /**
 106      * @param scrollPane an instance of the {@code JScrollPane}
 107      * @deprecated - Replaced by {@link #uninstallListeners(JComponent)}
 108      */
 109     @Deprecated
 110     public void uninstallListeners(JScrollPane scrollPane) {
 111         super.uninstallListeners(scrollPane);
 112         scrollPane.removePropertyChangeListener(scrollBarSwapListener);
 113     }
 114 
 115     /**
 116      * If the border of the scrollpane is an instance of
 117      * <code>MetalBorders.ScrollPaneBorder</code>, the client property
 118      * <code>FREE_STANDING_PROP</code> of the scrollbars
 119      * is set to false, otherwise it is set to true.
 120      */
 121     private void updateScrollbarsFreeStanding() {
 122         if (scrollpane == null) {
 123             return;
 124         }
 125         Border border = scrollpane.getBorder();
 126         Object value;
 127 
 128         if (border instanceof MetalBorders.ScrollPaneBorder) {
 129             value = Boolean.FALSE;
 130         }
 131         else {
 132             value = Boolean.TRUE;
 133         }
 134         JScrollBar sb = scrollpane.getHorizontalScrollBar();
 135         if (sb != null) {
 136             sb.putClientProperty
 137                    (MetalScrollBarUI.FREE_STANDING_PROP, value);
 138         }




  28 import javax.swing.*;
  29 import javax.swing.event.*;
  30 import javax.swing.border.*;
  31 import javax.swing.plaf.*;
  32 import javax.swing.plaf.basic.*;
  33 
  34 import java.awt.*;
  35 import java.beans.*;
  36 import java.awt.event.*;
  37 
  38 
  39 /**
  40  * A Metal L&amp;F implementation of ScrollPaneUI.
  41  * <p>
  42  * <strong>Warning:</strong>
  43  * Serialized objects of this class will not be compatible with
  44  * future Swing releases. The current serialization support is
  45  * appropriate for short term storage or RMI between applications running
  46  * the same version of Swing.  As of 1.4, support for long term storage
  47  * of all JavaBeans&trade;
  48  * has been added to the {@code java.beans} package.
  49  * Please see {@link java.beans.XMLEncoder}.
  50  *
  51  * @author Steve Wilson
  52  */
  53 @SuppressWarnings("serial") // Same-version serialization only
  54 public class MetalScrollPaneUI extends BasicScrollPaneUI
  55 {
  56 
  57     private PropertyChangeListener scrollBarSwapListener;
  58 
  59     /**
  60      * Constructs a new {@code MetalScrollPaneUI}.
  61      *
  62      * @param x a component
  63      * @return a new {@code MetalScrollPaneUI}
  64      */
  65     public static ComponentUI createUI(JComponent x) {
  66         return new MetalScrollPaneUI();
  67     }
  68 


  97     /**
  98      * {@inheritDoc}
  99      */
 100     protected void uninstallListeners(JComponent c) {
 101         super.uninstallListeners(c);
 102         c.removePropertyChangeListener(scrollBarSwapListener);
 103     }
 104 
 105     /**
 106      * @param scrollPane an instance of the {@code JScrollPane}
 107      * @deprecated - Replaced by {@link #uninstallListeners(JComponent)}
 108      */
 109     @Deprecated
 110     public void uninstallListeners(JScrollPane scrollPane) {
 111         super.uninstallListeners(scrollPane);
 112         scrollPane.removePropertyChangeListener(scrollBarSwapListener);
 113     }
 114 
 115     /**
 116      * If the border of the scrollpane is an instance of
 117      * {@code MetalBorders.ScrollPaneBorder}, the client property
 118      * {@code FREE_STANDING_PROP} of the scrollbars
 119      * is set to false, otherwise it is set to true.
 120      */
 121     private void updateScrollbarsFreeStanding() {
 122         if (scrollpane == null) {
 123             return;
 124         }
 125         Border border = scrollpane.getBorder();
 126         Object value;
 127 
 128         if (border instanceof MetalBorders.ScrollPaneBorder) {
 129             value = Boolean.FALSE;
 130         }
 131         else {
 132             value = Boolean.TRUE;
 133         }
 134         JScrollBar sb = scrollpane.getHorizontalScrollBar();
 135         if (sb != null) {
 136             sb.putClientProperty
 137                    (MetalScrollBarUI.FREE_STANDING_PROP, value);
 138         }


< prev index next >