mdh.hephaestus2.gamelib
Class StackLayout2

java.lang.Object
  |
  +--mdh.hephaestus2.gamelib.StackLayout2
All Implemented Interfaces:
LayoutManager, LayoutManager2

public final class StackLayout2
extends Object
implements LayoutManager2

StackLayout2 places one component on top of another (as seen in the Committee to Put Things On Top Of Other Things). The lines will be centered or left or right justified. Mind-bogglingly useful, astounding that Sun never wrote one of these.

Later: discovered that they had, they just hid it inside sun.* where nobody knew about it. Mine's better, anyway.

Later: updated to JDK 1.1, added random alignment on a lark.

99Feb08: Changed to String alignment parameter, and it now allows percentages of remaining width to be specified as integers-converted-to-String. "0" is the left margin, "100" is the right margin, "50" is centered.

99Feb12: Minor bug-fix in addLayoutComponent() - I wasn't checking for nulls.

Author:
Copyright © 1999-2000 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>

Field Summary
static String CENTER
           
static String FILL
           
static String LEFT
           
static String RANDOM
           
static String RIGHT
           
 
Constructor Summary
StackLayout2()
          default left alignment and gaps of 2, 2
StackLayout2(String align)
          default gaps of 2, 2
StackLayout2(String align, int hgap, int vgap)
           
 
Method Summary
 void addLayoutComponent(Component comp, Object constraints)
          Remembers that this one has a non-default position.
 void addLayoutComponent(String name, Component comp)
          implements LayoutManager
 float getLayoutAlignmentX(Container parent)
          implements LayoutManager2
 float getLayoutAlignmentY(Container parent)
          implements LayoutManager2
 void invalidateLayout(Container parent)
          implements LayoutManager2
 void layoutContainer(Container parent)
           
static void main(String[] args)
           
 Dimension maximumLayoutSize(Container parent)
          implements LayoutManager2
 Dimension minimumLayoutSize(Container parent)
           
 Dimension preferredLayoutSize(Container parent)
           
 void removeLayoutComponent(Component comp)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static final String LEFT
See Also:
Constant Field Values

CENTER

public static final String CENTER
See Also:
Constant Field Values

RIGHT

public static final String RIGHT
See Also:
Constant Field Values

FILL

public static final String FILL
See Also:
Constant Field Values

RANDOM

public static final String RANDOM
See Also:
Constant Field Values
Constructor Detail

StackLayout2

public StackLayout2()
default left alignment and gaps of 2, 2


StackLayout2

public StackLayout2(String align)
default gaps of 2, 2


StackLayout2

public StackLayout2(String align,
                    int hgap,
                    int vgap)
             throws IllegalArgumentException
Method Detail

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)
Remembers that this one has a non-default position. implements LayoutManager2

Specified by:
addLayoutComponent in interface LayoutManager2

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
implements LayoutManager

Specified by:
addLayoutComponent in interface LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(Container parent)
implements LayoutManager2

Specified by:
getLayoutAlignmentX in interface LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(Container parent)
implements LayoutManager2

Specified by:
getLayoutAlignmentY in interface LayoutManager2

invalidateLayout

public void invalidateLayout(Container parent)
implements LayoutManager2

Specified by:
invalidateLayout in interface LayoutManager2

layoutContainer

public void layoutContainer(Container parent)
Specified by:
layoutContainer in interface LayoutManager

main

public static void main(String[] args)

maximumLayoutSize

public Dimension maximumLayoutSize(Container parent)
implements LayoutManager2

Specified by:
maximumLayoutSize in interface LayoutManager2

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Specified by:
minimumLayoutSize in interface LayoutManager

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Specified by:
preferredLayoutSize in interface LayoutManager

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Specified by:
removeLayoutComponent in interface LayoutManager

toString

public String toString()
Overrides:
toString in class Object