[英]ScalaFX (JavaFX): Stage content does not resize on window resize
要检查这种意外行为,我只需将TextArea
直接放入PrimaryStage
包含的Scene
中:在应用程序启动时, TextArea
完全适合窗口(如预期的那样)。
但是如果我移动窗口的边框, TextArea
的大小不会改变,这是我试图解决的问题。
这是我的ScalaFX代码(我期望它的行为与JavaFX等效):
object MyApp extends JFXApp {
stage = new PrimaryStage {
title = "My App"
resizable = true // has no effect
maxWidth = Double.MaxValue // has no effect
maxHeight = Double.MaxValue // has no effect
val outputDisplay = new TextArea {
resizable = true // has no effect
maxWidth = Double.MaxValue // has no effect
maxHeight = Double.MaxValue // has no effect
hgrow = Priority.Always // has no effect
vgrow = Priority.Always // has no effect
}
scene = new Scene {
resizable = true // has no effect
maxWidth = Double.MaxValue // has no effect
maxHeight = Double.MaxValue // has no effect
fill = LightGreen
// add outputDisplay as content
content = outputDisplay
}
}
}
要使TextArea
正确调整大小,您需要一个布局。 例如, BorderPane
应该用作场景的content
。
有关布局的更多信息,请访问http://docs.oracle.com/javase/8/javafx/layout-tutorial/builtin_layouts.htm#JFXLY102
UPDATE
在查看ScalaFX源代码后,我意识到应该使用
root
而不是场景中的content
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.