Bài viết phổ biến của tác giả
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在舞台上有一个场景。场景的宽度为 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/
Tôi là một lập trình viên xuất sắc, rất giỏi!