Class LayoutConstraint

java.lang.Object
swingtree.layout.LayoutConstraint

public final class LayoutConstraint extends Object
A wrapper for mig layout constraint string to avoid the inherent brittleness of strings... which can be merged with other instances of this class through the and(LayoutConstraint) method, which is in essence a wither method.
Here how this class would typically be used in a swing-tree UI:

  	import static swingtree.UI.*;

      public class MyView extends JPanel {
          public MyView() {
          	of(this).withLayout(FILL.and(GROW).and(WRAP(3)))
          	.add(LEFT, label("Name:") )
          	.add(GROW.and(SPAN), textField("name") )
          	.add(LEFT, label("Address:") )
          	.add(GROW.and(SPAN), textField("address") )
           }
      }
  
As you can see this class is not used directly, but rather in the form of static constants as part of the UI class. You can define your own mig layout constraints as static constants in your own code by using the of(String...) method.
  • Method Details

    • of

      public static LayoutConstraint of(String... layoutConstraints)
      Create a new LayoutConstraint with the given layout constraints
      Parameters:
      layoutConstraints - the layout constraints in the form of a string array.
      Returns:
      a new LayoutConstraint, which may represent a single component or a group of layout constraints.
    • and

      Create a new LayoutConstraint with the provided LayoutConstraint merged with this one.
      Parameters:
      attr - the LayoutConstraint to merge with this one
      Returns:
      a new LayoutConstraint with the provided LayoutConstraint merged with this one
    • and

      public LayoutConstraint and(String... layoutConstraints)
      Create a new LayoutConstraint with the provided layout constraints merged with this one.
      Parameters:
      layoutConstraints - the string layout constraints to merge with this one
      Returns:
      a new LayoutConstraint with the provided layout constraints merged with this one
    • _and

      protected swingtree.layout.AbstractConstraint _and(swingtree.layout.AbstractConstraint attr, swingtree.layout.AbstractConstraint newAttr)
    • toString

      public String toString()
      Overrides:
      toString in class Object