1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4  
     5  import org.aswing.BoxLayout;
     6  import org.aswing.Component;
     7  import org.aswing.Container;
     8  import org.aswing.JPanel;
     9  
    10  /**
    11   * @author iiley
    12   */
    13  class org.aswing.Box extends JPanel{
    14  		
    15  	/**
    16  	 * Box(axis:Number, gap:Number)<br>
    17  	 * Box(axis:Number) default gap to 0.
    18  	 * Creates a panel with a BoxLayout.
    19  	 * @param axis (optional)the axis of layout, default is X_AXIS
    20  	 *  {@link org.aswing.BoxLayout#X_AXIS} or {@link org.aswing.BoxLayout#Y_AXIS}
    21       * @param gap (optional)the gap between each component, default 0
    22  	 * @see org.aswing.SoftBoxLayout
    23  	 */
    24  	public function Box(axis:Number, gap:Number){
    25  		super();
    26  		setName("Box");
    27  		setLayout(new BoxLayout(axis, gap));
    28  	}
    29  	
    30  	/**
    31  	 * Creates and return a Horizontal Box.
    32       * @param gap (optional)the gap between each component, default 0
    33       * @return a horizontal Box.
    34  	 */	
    35  	public static function createHorizontalBox(gap:Number):Box{
    36  		return new Box(BoxLayout.X_AXIS, gap);
    37  	}
    38  	
    39  	/**
    40  	 * Creates and return a Vertical Box.
    41       * @param gap (optional)the gap between each component, default 0
    42       * @return a vertical Box.
    43  	 */
    44  	public static function createVerticalBox(gap:Number):Box{
    45  		return new Box(BoxLayout.Y_AXIS, gap);
    46  	}
    47  	
    48  	public static function createHorizontalGlue():Component{
    49  		var glue:Container = new JPanel();
    50  		glue.setOpaque(false);
    51  		glue.setMinimumSize(0, 0);
    52  		glue.setPreferredSize(0, 0);
    53  		glue.setMaximumSize(0, Number.MAX_VALUE);
    54  		return glue;
    55  	}
    56  	
    57  	public static function createVerticalGlue():Component{
    58  		var glue:Container = new JPanel();
    59  		glue.setOpaque(false);
    60  		glue.setMinimumSize(0, 0);
    61  		glue.setPreferredSize(0, 0);
    62  		glue.setMaximumSize(Number.MAX_VALUE, 0);
    63  		return glue;
    64  	}
    65  }
    66