/*
 * @(#)ScrollPaneLayout2.java  1.3  2006-07-23
 *
 * Copyright (c) 1999-2006 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

package ch.randelshofer.gui;

import java.awt.*;
import javax.swing.*;
/**
 * Objects of this class behave essentially like
 * javax.swing.ScrollPaneLayout but treats the top
 * right corner specially.
 * <p>
 * If there is a component in the top right corner, it
 * is granted to be visible when the vertical scroll bar
 * is visible.
 *
 * @author  werni
 */
public class ScrollPaneLayout2 extends ScrollPaneLayout implements javax.swing.plaf.UIResource  {
    
    /** Creates a new instance of CornerLayout2 */
    public ScrollPaneLayout2() {
    }
    
    /**
     * Same as ScrollPaneLayout.layoutContainer but the top right
     * corner is treated specially.
     *
     * @param parent the <code>Container</code> to lay out
     */
    public void layoutContainer(Container parent) {
        super.layoutContainer(parent);
        
        if (upperRight != null && rowHead == null) {
            if (vsb != null && vsb.isVisible()) {
                Rectangle vsbR = vsb.getBounds();
                
                upperRight.setBounds(vsbR.x, vsbR.y,
                vsbR.width, vsbR.width);
                
                vsb.setBounds(vsbR.x, vsbR.y + vsbR.width,
                vsbR.width, vsbR.height - vsbR.width);
            }
        }
         
    }
}
