Search code examples
playntripleplay

How to get a Borderlayout to fill its container?


I am a GWT programmer trying to get to grips with using PlayN with Tripleplays gui library.

Having a little bit of trouble working out how to get a border layout filling up all the space of its container. (presumably with the middle space expanding to fill the available size)

BorderLayout border = new BorderLayout(3);
Group mainLayout = new Group(border);

    mainLayout.setConstraint(AxisLayout.stretched());


   Button Center= new Button("test");
  Center.setConstraint(BorderLayout.CENTER);

  mainLayout.add(Top);
  mainLayout.add(Bottom);
  mainLayout.add(Left);
      mainLayout.add(Center);

Top Bottom and Left are similarly specified to BorderLayout.Left, top etc.

the whole thing is then added to the root screen with

  _root.setConstraint(AxisLayout.stretched());
  _root.add(0, mainLayout);

(_root itself just has a AxisLayout.vertical() ...which I am assuming makes it act somewhat like a gwt vertical panel)

At the moment the vertical space seems to be filled, but not the horizontal.

Any ideas where I am going wrong?


Solution

  • I would suggest to set

    border.setConstraint(AxisLayout.stretched());
    

    before adding border to mainLayout. This will tell mainLayout to strech this child widget.