java - 使用 MiGLayout 修复基于百分比的网格

标签 java javafx miglayout

我正在尝试使用 MiGLayout 创建一个对其子项强制执行的网格。这意味着,如果我将一个子项插入网格位置 (1,1) 并且网格的大小为 [10%!],则该子项不能更大并且不能与其他单元格重叠。必须缩小子项以适合网格单元格。

这是我到目前为止所拥有的:

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

现在,我在 Grid 1,1 中插入一个大组件(一张我无法控制的图片),如下所示:

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

但是,这似乎根本不限制 ImageView。

我如何告诉 MiGLayout 我希望将“myImageView”放入网格 1,1 中并调整其大小以适合?有“适合”这个关键词吗? :)

请注意,用像素/点/毫米/厘米/英寸指定任何内容都不是我想要的。我的应用程序始终全屏运行并且必须无缝缩放(它不是传统的表单应用程序,它是使用 JavaFX 的视频系统)。

最佳答案

根据docs,看起来百分比是受支持的。 :

Overrides the default size of the component that is set by the UI delegate or by the developer explicitly on the component. The size is specified as a BoundSize. See the Common Argument Types section above for an explanation. Note that expressions is supported and you can for instance set the size for a component with "width pref+10px" to make it 10 pixels larger than normal or "width max(100, 10%)" to make it 10% of the container's width, but a maximum of 100 pixels.

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

关于java - 使用 MiGLayout 修复基于百分比的网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9659178/

相关文章:

java - 在启动时获取许多项目时不断出现内存不足错误

java - 在 play.db.ebean.EbeanPlugin 中找不到合适的构造函数,如何解决此问题?

javafx - JxBrowser HEAVYWEIGHT 在 WINDOW_CLOSE_REQUEST 上处置

java - 将单元格合并到 MigLayout?

java - 如何在 MigLayout 中获得一个向右对齐的按钮

java - 限制 xalan 转换生成的编号中使用的字母

java - JIT 的总竞技场页面 - 这是什么意思?

java - 键盘操作事件在 JavaFX 中不起作用

java - 如何在 Javafx 中制作弧线动画

Java MigLayout非法约束 'dock'