Lemur: FillMode.None and container stretching

Hello all!

First of all, Merry Christmas to you all!

I’m trying to fiddle around with layouts and I can’t seem to make it work the way I would like to. So the thing is I have three panels. Code and picture speak for themselves:

        // Grey on image. Contains the following two containers (healthBar and hotbar)
        Container container = new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.None, FillMode.None)); 
        // Red on image
        Container healthBar = new Container(new SpringGridLayout());
        // Green on image
        Container hotbar = new Container(new SpringGridLayout());

        container.addChild(healthBar, 0, 0);
        container.addChild(hotbar, 1, 0);


A quote from FillMode.None:

None - indicates that none of the children will be stretched and there default size will always be used.

Between healtBar and hotbar, healthbar is shorter. As you guys can see on the image, I want it to be one row above the hotbar and I want healthBar to keep its size in the cell. Whatever I do healthBar will be stretched to the size of hotbar.

What am I doing wrong?

And with this inertia I have, let me answer my own question:

healthBar.setInsetsComponent(new DynamicInsetsComponent(0.5f, 0.5f, 0.5f, 0.5f));
hotbar.setInsetsComponent(new DynamicInsetsComponent(0.5f, 0.5f, 0.5f, 0.5f));

This component will set the containers’ insets dynamically so they will be in the middle with their own sizes. So the end result is what I originally wanted: the top part of the image.

I think you still need to call .setPreferredSize() when using fillmode.none. And then it will also be alligned to the left and youd need to center it still.

So using insets like you did in your follow up post looks like a good solution.

Another way would be to attach a small container to the left of your heath bar and give that container a preferredSize equal to the desired margins.

Or you can also use the BorderLayout (in place of springGridlayout) and then you could attach your component to the BorderLayout.Position.Center and it wil be centered in the container

It looks like I’m not the only one who is on JME forums on christmas. :smiley: Thanks for the answer!

1 Like