Package swingtree

Class UILayoutConstants

java.lang.Object
swingtree.UILayoutConstants
Direct Known Subclasses:
UIFactoryMethods

public abstract class UILayoutConstants extends Object
Essentially just a namespace for static layout constants for the MigLayout LayoutManager type.
This class is not intended to be instantiated!

The constants as well as static factory methods in this class are intended to be used like this:

 import static swingtree.UI.*;
 //...
 panel(FILL.and(WRAP(2)))
 .withPrefSize(500, 300)
 .add(GROW,
   panel(FILL_X.and(WRAP(2)),"[shrink][grow]")
   .add(label("Username"))
   .add(GROW_X,
     textField(vm.username())
   )
   .add(SHRINK_X, label("Password"))
   .add(GROW_X,
     passwordField(vm.password())
   )
 )
 .add(GROW,
   panel(FILL_X.and(WRAP(2)),"[shrink][grow]")
   .add(label("Email"))
   .add(GROW_X,
     textField(vm.email())
   )
   .add(SHRINK_X, label("Gender"))
   .add(GROW_X,
     comboBox(vm.gender())
   )
 )
 .add(GROW_X,
   panel(FILL_X.and(WRAP(1)))
   .add(GROW_X,
     checkBox("I accept!", vm.termsAccepted())
   )
   .add(GROW_X,
     button("Register")
     .onClick( it -> vm.register() )
   )
 )
 .add(GROW_X,
   panel(FILL_X.and(WRAP(1)))
   .withBorderTitled("Feedback")
   .add(GROW_X,
     boldLabel(
       vm.feedback()
     )
     .withForeground(vm.feedbackColor())
   )
 )
 .add(GROW_X.and(SPAN), button("RESET").onClick( it -> vm.reset() ));
 
In this little example form we can see how the constants are used to create a form with a grid layout.
The FILL constant is used to make the panels fill the entire width of the parent panel.
The WRAP(int) constant is used to make the panels wrap after n components have been added to them.
The GROW constant is used to make the panels grow vertically to fill the entire height of the parent panel.
... and so on.