tags:

views:

21

answers:

1

Hi, I'm trying to construct a simple status panel using MigLayout as follows:

setLayout(new MigLayout("fillx", "[][p]")); // removing constructor args makes no difference
add(createStatusLabel(), "span 2, wrap");
add(createProgressBar(), "growx, pushx");
add(createCancelButton(), "");

This works fine as long as the status message displayed by the status label is short enough to fit within the current panel's size (the cancel button remains right-justified, and the progress bar resizes to take up the remaining space). If the status message is too long, it is not cropped, and causes the area to exceed the bounds of the container, resulting in the cancel button being pushed off screen.

Any suggestions on how to prevent this from happening?

Thanks

A: 

Try setting the maximum width of the label to 100%.

You can do this by changing the layout for the label to "span 2, wrap, wmax 100%"

In my tests, I found that it still didn't look quite right, so you may want to subtract a little bit of length (something like wmax 100% - 10px) to bring it away from the edge.

deterb
Thanks - I was just logging in to answer my own question with the same solution, but you beat me to it. I also found 100% was too large - possibly not allowing for the border or insets. I also tried using the "parent" reference in the width expression, but I see MigLayout no longer allows this. (I would vote you up but I don't have enough points yet)
zorgbargle