SSeparator.java :  » Swing-Library » wings3 » org » wings » Java Open Source

Java Open Source » Swing Library » wings3 
wings3 » org » wings » SSeparator.java
package org.wings;

/**
 * 
 */
public class SSeparator extends SComponent {

    private static final long serialVersionUID = -6257881596567546337L;
    
    private static final SDimension initialDimensionH = new SDimension("100%", "1px");
    private static final SDimension initialDimensionV = new SDimension("1px", "17px");
    
    private int orientation = -1;

    public SSeparator() {
        this(SConstants.HORIZONTAL);
    }

    public SSeparator(final int orientation) {
        setOrientation(orientation);
    }

    public int getOrientation() {
        return orientation;
    }

    public void setOrientation(final int orientation) {
        if (isDifferent(this.orientation, orientation)) {
            switch (orientation) {
            case SConstants.HORIZONTAL:
                if (getPreferredSize() == null) {
                    setPreferredSize(initialDimensionH);
                }
                addStyle("horizontal");
                break;
            case SConstants.VERTICAL:
                if (getPreferredSize() == null) {
                    setPreferredSize(initialDimensionV);
                }
                addStyle("vertical");
                break;
            default:
                throw new IllegalArgumentException("Orientation must be one of: HORIZONTAL, VERTICAL");
            }
            this.orientation = orientation;
            reload();
        }
        
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.