sách gpt4 ai đã đi

java - 阶段 : Not resizing to Scene

In lại 作者:行者123 更新时间:2023-12-04 03:34:01 28 4
mua khóa gpt4 Nike

我在舞台上有一个场景。场景的宽度为 337.0 像素。但是,当我将它添加到舞台时,舞台的大小为 337.6 像素,由于 0.6 像素的差异,在屏幕的右边缘留下了一个白色间隙。

我尝试使用 stage.sizeToScene(),但它不起作用。我还尝试通过 stage.setWidth(337) 手动设置舞台的宽度。不影响舞台的宽度,依然是337.6。

我尝试了以下操作:stage.setWidth(337.0)。然后,当我在控制台上使用 stage.getWidth() 打印舞台宽度时,打印的值为 337.0,但实际上,0.6 像素的白线仍然存在。

我尝试过以下操作:

stage.hide();
stage.show();

这行得通,它删除了白线,但它显示了看起来非常糟糕的窗口切换。有没有一种方法可以在不像上面那样切换窗口的情况下执行相同的操作。

我们将不胜感激。

1 Câu trả lời

我在为我的舞台设置正确尺寸时遇到了类似的问题。

对我的情况有帮助的是使用:

stage.setMinWidth(newActiveScene.getRoot().minWidth(-1));
stage.setMinHeight(newActiveScene.getRoot().minHeight(-1));

TRONG sân khấu 是您正在使用的舞台,newActiveScene 是您在舞台上设置的新场景。

实际上我正在使用一种方法在舞台上设置新场景,看起来像这样:

/**
* Sets a new active {@link Scene} on the stage.
*
* @param newActiveScene the new scene to show
*/
public static void setActiveScene(Scene newActiveScene) {
stage.setScene(newActiveScene);
stage.setMinWidth(newActiveScene.getRoot().minWidth(-1));
stage.setMinHeight(newActiveScene.getRoot().minHeight(-1));
}

TRONG sân khấu 是使用的舞台。这假定 stage.show() 已被调用一次(例如在初始化舞台时)。

关于java - 阶段 : Not resizing to Scene,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67297392/

28 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com