[英]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.