To inspect this unexpected behavior, I simply put a TextArea
directly into the Scene
contained by the PrimaryStage
: On app start, the TextArea
exactly fits the window (as expected).
But the size of the TextArea
does not change if I move the window's borders, which is the problem I am trying to solve.
Please see my Screenshot
This is my ScalaFX code (which I expect to act exactly like its JavaFX equivalent):
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
}
}
}
For TextArea
to resize properly you need a layout. For example BorderPane
should be used as scene's content
.
More about layouts can found at http://docs.oracle.com/javase/8/javafx/layout-tutorial/builtin_layouts.htm#JFXLY102
UPDATE
After looking at the ScalaFX source code,I realized that
root
should be used instead ofcontent
on the scene
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With