1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4  
     5  import org.aswing.ASWingConstants;
     6  import org.aswing.Component;
     7  import org.aswing.plaf.SeparatorUI;
     8  import org.aswing.UIManager;
     9  
    10  /**
    11   * <code>JSeparator</code> provides a general purpose component for
    12   * implementing divider lines - most commonly used as a divider
    13   * between menu items that breaks them up into logical groupings.
    14   * Instead of using <code>JSeparator</code> directly,
    15   * you can use the <code>JMenu</code> or <code>JPopupMenu</code>
    16   * <code>addSeparator</code> method to create and add a separator.
    17   * <code>JSeparator</code>s may also be used elsewhere in a GUI
    18   * wherever a visual divider is useful.
    19   * 
    20   * @author iiley
    21   */
    22  class org.aswing.JSeparator extends Component {
    23  	
    24      /** 
    25       * Horizontal orientation.
    26       */
    27      public static var HORIZONTAL:Number = ASWingConstants.HORIZONTAL;
    28      /** 
    29       * Vertical orientation.
    30       */
    31      public static var VERTICAL:Number   = ASWingConstants.VERTICAL;
    32  	
    33  	private var orientation:Number;
    34  	
    35  	/**
    36  	 * JSeparator(orientation:Number)<br>
    37  	 * JSeparator() default orientation to HORIZONTAL;
    38  	 * <p>
    39  	 * @param orientation (optional) the orientation.
    40  	 */
    41  	public function JSeparator(orientation:Number){
    42  		this.orientation = (orientation == undefined ? HORIZONTAL : orientation);
    43  		setFocusable(false);
    44  		updateUI();
    45  	}
    46  	
    47  	public function getUI():SeparatorUI{
    48  		return SeparatorUI(ui);
    49  	}
    50  	
    51  	public function setUI(ui:SeparatorUI):Void{
    52  		super.setUI(ui);
    53  	}
    54  	
    55  	public function updateUI():Void{
    56  		setUI(SeparatorUI(UIManager.getUI(this)));
    57  	}
    58  	
    59  	public function getUIClassID():String{
    60  		return "SeparatorUI";
    61  	}
    62  	
    63  	public function getOrientation():Number{
    64  		return orientation;
    65  	}
    66  	
    67  	public function setOrientation(orientation:Number):Void{
    68  		if (this.orientation != orientation){
    69  			this.orientation = orientation;
    70  			revalidate();
    71  			repaint();
    72  		}
    73  	}
    74  }
    75