JavaView® v2.12

jv.objectGui
Class GuiStackLayout

java.lang.Object
  |
  +--jv.objectGui.GuiStackLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.io.Serializable

public final class GuiStackLayout
extends java.lang.Object
implements java.io.Serializable, java.awt.LayoutManager

Simple layout manager for filling a panel horizontally or vertically. StackLayout is a LayoutManager that arranges components in a vertical (or horizontal) strip aligning them at right, left or centered, and/or filling them to take up any extra vertical or horizontal space. Arrangement tags are provided by using the add(tag,component) form to add components to the container. The tag consists of one or more of the following, with the two forms applying to horizontal or vertical dimension.

 Positioning:
 	  "Center"                : centered horizontally & vertically (the default)
 	  "Left"    or "Top"      : pushed at the left|top edge.
 	  "Right"   or "Bottom"   : pushed against the right|top edge
 Sizing:
 	  "Wide"    or "Tall"     : filled to use available space.
 	  "Wide*#"  or "Tall*#"   : filled but weighted by the number #.
 	  "Fill" (or "Fill*#")    : filled in both directions.
 	  "Width=#" or "Height=#" : given explicit width|height
 Margins:
 	  "Flush"                 : margins are not added around this component.
 
By default, a component is centered in both directions. The available space along the orientation is divided between the filled components. A common idiom is to build a complicated panel out of, say, a vertical stack of horizontal stacks (both using GuiStackLayout). In that case, it would usually be good to add the horizontal panels using the tag "Wide Flush", so that spacing comes out evenly.

Much of what can be done with GridBagLayout can be achieved by combining a set of subpanels using GuiStackLayout, but typically more concisely. On the other hand, with GuiStackLayout there is less compile time checking of the layout.

Compare jv.object.PsStackLayout for a much lighter implementation.

Version:
in 1998 (kp) Added to JavaView as GuiStackLayout, original name StackLayout conflicted with existing class.
Author:
Bruce R. Miller (bruce.miller@nist.gov)
Contribution of the National Institute of Standards and Technology,
not subject to copyright.
See Also:
PsStackLayout, Serialized Form

Field Summary
static int HORIZONTAL
          The orientation constant for horizontal layouts.
static int VERTICAL
          The orientation constant for vertical layouts.
 
Constructor Summary
GuiStackLayout()
          Create a horizontal StackLayout.
GuiStackLayout(int orientation)
          Create a StackLayout with the given orientation.
GuiStackLayout(int orientation, int margin)
          Create a StackLayout with the given orientation and space between components.
 
Method Summary
 void addLayoutComponent(java.lang.String tag, java.awt.Component comp)
          Add the specified component to the layout, parsing the layout tag.
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculate the minimum size dimensions for the specififed container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculate the preferred size dimensions for the specififed container.
 void removeLayoutComponent(java.awt.Component comp)
          Remove the specified component from the layout.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
The orientation constant for horizontal layouts.

VERTICAL

public static final int VERTICAL
The orientation constant for vertical layouts.
Constructor Detail

GuiStackLayout

public GuiStackLayout()
Create a horizontal StackLayout.

GuiStackLayout

public GuiStackLayout(int orientation)
Create a StackLayout with the given orientation.

GuiStackLayout

public GuiStackLayout(int orientation,
                      int margin)
Create a StackLayout with the given orientation and space between components.
Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String tag,
                               java.awt.Component comp)
Add the specified component to the layout, parsing the layout tag.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove the specified component from the layout.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculate the minimum size dimensions for the specififed container.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculate the preferred size dimensions for the specififed container.
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the specified container.
Specified by:
layoutContainer in interface java.awt.LayoutManager

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.