FileDocCategorySizeDatePackage
MetalScrollPaneUI.javaAPI DocJava SE 5 API4253Fri Aug 26 14:58:08 BST 2005javax.swing.plaf.metal

MetalScrollPaneUI

public class MetalScrollPaneUI extends BasicScrollPaneUI
A Metal L&F implementation of ScrollPaneUI.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.

version
1.20 09/08/04
author
Steve Wilson

Fields Summary
private PropertyChangeListener
scrollBarSwapListener
Constructors Summary
Methods Summary
protected java.beans.PropertyChangeListenercreateScrollBarSwapListener()

        return new PropertyChangeListener() {
	    public void propertyChange(PropertyChangeEvent e) {
		  String propertyName = e.getPropertyName();
		  if (propertyName.equals("verticalScrollBar") ||
		      propertyName.equals("horizontalScrollBar")) {
                      JScrollBar oldSB = (JScrollBar)e.getOldValue();
                      if (oldSB != null) {
                          oldSB.putClientProperty(
                              MetalScrollBarUI.FREE_STANDING_PROP, null);
                      }
                      JScrollBar newSB = (JScrollBar)e.getNewValue();
                      if (newSB != null) {
                          newSB.putClientProperty(
                              MetalScrollBarUI.FREE_STANDING_PROP,
                              Boolean.FALSE);
                      }
		  }	  
                  else if ("border".equals(propertyName)) {
                      updateScrollbarsFreeStanding();
                  }
	}};
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent x)

	return new MetalScrollPaneUI();
    
public voidinstallListeners(javax.swing.JScrollPane scrollPane)

        super.installListeners(scrollPane);
	scrollBarSwapListener = createScrollBarSwapListener();
	scrollPane.addPropertyChangeListener(scrollBarSwapListener);
    
public voidinstallUI(javax.swing.JComponent c)


        super.installUI(c);

	JScrollPane sp = (JScrollPane)c;
        updateScrollbarsFreeStanding();
    
public voiduninstallListeners(javax.swing.JScrollPane scrollPane)

        super.uninstallListeners(scrollPane);

	scrollPane.removePropertyChangeListener(scrollBarSwapListener);
    
public voiduninstallUI(javax.swing.JComponent c)

        super.uninstallUI(c);

	JScrollPane sp = (JScrollPane)c;
	JScrollBar hsb = sp.getHorizontalScrollBar();
	JScrollBar vsb = sp.getVerticalScrollBar();
        if (hsb != null) {
            hsb.putClientProperty( MetalScrollBarUI.FREE_STANDING_PROP, null);
        }
        if (vsb != null) {
            vsb.putClientProperty( MetalScrollBarUI.FREE_STANDING_PROP, null);	
        }
    
private voidupdateScrollbarsFreeStanding()
If the border of the scrollpane is an instance of MetalBorders.ScrollPaneBorder, the client property FREE_STANDING_PROP of the scrollbars is set to false, otherwise it is set to true.

        if (scrollpane == null) {
            return;
        }
        Border border = scrollpane.getBorder();
        Object value;

        if (border instanceof MetalBorders.ScrollPaneBorder) {
            value = Boolean.FALSE;
        }
        else {
            value = Boolean.TRUE;
        }
        JScrollBar sb = scrollpane.getHorizontalScrollBar();
        if (sb != null) {
            sb.putClientProperty
                   (MetalScrollBarUI.FREE_STANDING_PROP, value);
        }
        sb = scrollpane.getVerticalScrollBar();
        if (sb != null) {
            sb.putClientProperty
                   (MetalScrollBarUI.FREE_STANDING_PROP, value);
        }