bb.gui
Class LineLayout.UnitTest

java.lang.Object
  extended by bb.gui.LineLayout.UnitTest
Enclosing class:
LineLayout

public static class LineLayout.UnitTest
extends Object

See the Overview page of the project's javadocs for a general description of this unit test class.


Field Summary
private static Border border
           
private static int nextX
           
private static int nextY
           
 
Constructor Summary
private LineLayout.UnitTest()
          This private constructor suppresses the default (public) constructor, ensuring non-instantiability.
 
Method Summary
private static JPanel buildExampleBoxLayoutFails()
          Is the result of buildExampleBoxLayoutWorks, but have added below it 2 JButtons (whose total length is significantly less either JLabel) in a sub-JPanel that is center-justified.
private static JPanel buildExampleBoxLayoutWorks()
          This adds 2 JLabels into a JPanel with a vertical BoxLayout LayoutManager.
private static JPanel buildExampleLineLayoutDoesFancyAlignment()
          Adds 5 JLabels in a vertical Linelayout.
private static JPanel buildExampleLineLayoutWorks()
          Is the result of buildExampleBoxLayoutFails, but with a new LineLayout swapped in as a replacement LayoutManager.
private static JFrame buildFrame(String title, JComponent contents)
           
private static JPanel buildTwoHorizontalButtons()
           
static void main(String[] args)
          This method may be called to demonstrate how Sun's BoxLayout fails while LineLayout works.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

border

private static final Border border

nextX

private static int nextX

nextY

private static int nextY
Constructor Detail

LineLayout.UnitTest

private LineLayout.UnitTest()
This private constructor suppresses the default (public) constructor, ensuring non-instantiability.

Method Detail

main

public static void main(String[] args)
This method may be called to demonstrate how Sun's BoxLayout fails while LineLayout works. It brings up a series of JFrames that demonstrate various points. Execute "java bb.gui.LineLayout$UnitTest" (on Windoze) to see this.


buildFrame

private static JFrame buildFrame(String title,
                                 JComponent contents)

buildExampleBoxLayoutWorks

private static JPanel buildExampleBoxLayoutWorks()
This adds 2 JLabels into a JPanel with a vertical BoxLayout LayoutManager. They should be displayed as expected (one on top of the other, both left justified).


buildExampleBoxLayoutFails

private static JPanel buildExampleBoxLayoutFails()
Is the result of buildExampleBoxLayoutWorks, but have added below it 2 JButtons (whose total length is significantly less either JLabel) in a sub-JPanel that is center-justified. Should see that the JLabels are now incorrectly right justified while the 2 JButtons are incorrectly left justified! Why should adding a new (and shorter, at that) Component screw up existing alignment? Looking at Sun's source code, it seems as if the incomprehensible SizeRequirements class is probably to blame...


buildTwoHorizontalButtons

private static JPanel buildTwoHorizontalButtons()

buildExampleLineLayoutWorks

private static JPanel buildExampleLineLayoutWorks()
Is the result of buildExampleBoxLayoutFails, but with a new LineLayout swapped in as a replacement LayoutManager. Should see that now the alignment of the JLabels is preserved as expected.


buildExampleLineLayoutDoesFancyAlignment

private static JPanel buildExampleLineLayoutDoesFancyAlignment()
Adds 5 JLabels in a vertical Linelayout. Each JLabel has a different x-alignement, that regularly increases as go down the line. Should see that the JLabels displayed in a diagonal, which illustrates the fancy alignment that LineLayout is capable of.