1

I am trying to create a grid with MiGLayout that is enforced on its children. This means that if I insert a child into grid position (1,1) and the grid's size is [10%!] that this child must NOT be bigger and overlap other cells. The child must be shrunk to fit the Grid cell.

This is what I have so far:

new MigPane("", "[5%!][20%!][5%!][65%!][5%!]", "[45%!][50%!][5%!]");

Now, I insert a big component (a picture that I have no control over) in Grid 1,1, like this:

migPane.add(myImageView, "cell 1 1, width 100%!");

However, that does not seem to restrict the ImageView at all.

How do I tell MiGLayout that I want "myImageView" to be put in grid 1,1 and size it to fit? Is there a "fit" keyword? :)

Note that specifying anything with pixels/points/mm/cm/inches is NOT what I want. My app always runs full-screen and must scale seamlessly (it is not a traditional form app, it is a video system using JavaFX).

4

1 回答 1

0

根据文档,看起来支持百分比:

覆盖由 UI 委托或开发人员在组件上显式设置的组件的默认大小。大小被指定为 BoundSize。有关说明,请参阅上面的常见参数类型部分。请注意,表达式是受支持的,例如,您可以使用“width pref+10px”设置组件的大小,使其比正常值大 10 个像素,或“width max(100, 10%)”使其成为容器的 10%宽度,但最大为 100 像素。

也许尝试类似:"width max(100%, 100%)"

于 2012-03-11T22:08:58.147 回答