JavaFX中的动态/即时调整大小 [英] Dynamic/instant resize in JavaFX

查看:472
本文介绍了JavaFX中的动态/即时调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建(立即)动态调整大小的JavaFX应用程序?现在我编写了一个动态调整大小的简单应用程序,但布局更改直到拖动时释放鼠标按钮后才会显示。我希望在此按钮发布之前立即看到结果/布局更改。

How do you create a JavaFX application that (instantly) dynamically resizes? Right now I have coded a simple application that dynamically resizes but the layout changes don't display until after the release of the mouse button on a drag. I want instantly see the results/layout changes before this button release.

我假设这是通过将正确的值/控件与反向绑定来完成的...任何帮助都会很棒!



编辑:

I'm assuming this is done by just binding the correct values/controls with inverse... Any help would be great!


以下是我的工作方式(感谢Praeus)。正如他所说,我必须将我的顶级容器/布局宽度和高度绑定到scene.width和scene.height。 -

Here's how I got things working (thanks to Praeus). Exactly as he said, I had to bind my top level container/layout width and height to scene.width and scene.height. --

var scene:Scene;

阶段{

title:应用程序标题

场景:场景=场景{

内容:[

XMigLayout {

width:bind scene.width;

高度:绑定scene.height;

...}]}}

Stage {
title: "Application title"
scene: scene = Scene {
content: [
XMigLayout {
width: bind scene.width;
height: bind scene.height;
...}]}}

推荐答案

实际上,如果您已经将所有内容组织成布局,那么您可能只需绑定顶级布局容器的宽度和scene.width和scene.height的高度。我不认为顶级布局控件是由任何东西管理的,因此您可以安全地直接设置布局控件的宽度和高度。如果这不起作用,那么您可能成功绑定layoutInfo的宽度和高度。

Actually if you've already organized everything into layouts, then you might be able to just bind the top level layout container(s) width and height to the scene.width and scene.height. I don't think top level layout controls are managed by anything, so you may be safe just setting width and height of the layout control directly. If that doesn't work then you might have success binding the layoutInfo width and height.

理想情况下,您希望在诉诸绑定之前使用布局管理。过度绑定可能是性能问题,并且在调整大小时可能导致重绘速度变慢。在这种情况下,您可以只使用顶级容器的绑定,然后顶级容器的所有子级都应相应地调整大小。至少我认为这应该有效。

Ideally you want to use layout management before resorting to binds. Excessive binds can be a performance problem, and can lead to slow redraws as you are resizing. In this case you can probably just use binds for the top level container, and then all of the children of the top level container should resize accordingly. At least I think that should work.

这篇关于JavaFX中的动态/即时调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆