ide*_*xer 5 java scala javafx scalafx
检查这种意外的行为,我只是把一个TextArea
直接进入Scene
载有PrimaryStage
:在应用程序启动时,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
}
}
}
Run Code Online (Sandbox Code Playgroud)
为了TextArea
正确调整大小,您需要一个布局。例如BorderPane
应该用作场景的content
.
有关布局的更多信息,请访问http://docs.oracle.com/javase/8/javafx/layout-tutorial/builtin_layouts.htm#JFXLY102
更新
查看ScalaFX源代码后,我意识到
root
应该使用而不是content
在场景中
归档时间: |
|
查看次数: |
908 次 |
最近记录: |