How can I make a TextArea
take the full width and height of the parent pane.
I tried this:
TextArea textArea = new TextArea();
textArea.setScaleX( 100 );
textArea.setScaleY( 100 );
but the element defined in the top via parent.setTop(...)
was covered.
Reducing the scaleY
had no effect.
What else do I have to do to achieve this?
Thanks
prefWidth(double height) Called during layout to determine the preferred width for this node. DoubleProperty.
getChildren. Gets the list of children of this Parent .
How do I change the size of TextField in JavaFX? One common way to do that is to place a label control immediately to the left of the text field. Label lblName = new Label("Name:"); lblName. setMinWidth(75); TextField txtName = new TextField(); txtName.
Button SizeThe methods setMinWidth() and setMaxWidth() sets the minimum and maximum width the button should be allowed to have. The method setPrefWidth() sets the preferred width of the button. When there is space enough to display a button in its preferred width, JavaFX will do so.
The MAX_VALUE solution is a bit hacky and could cause performance issues. Also, the answer to this could depend on what your parent container is. Anyway, a better way to do it would be like this:
textArea.prefWidthProperty().bind(<parentControl>.prefWidthProperty());
textArea.prefHeightProperty().bind(<parentConrol>.prefHeightProperty());
You may also want to bind the preferred properties to the actual properties, especially if the parent is using it's computed dimensions rather than explicit ones:
textArea.prefWidthProperty().bind(<parentControl>.widthProperty());
textArea.prefHeightProperty().bind(<parentConrol>.heightProperty());
It's also possible to do this without using binding by overriding the layoutChildren() method of the parent container and calling
textArea.resize(getWidth(), getHeight());
Don't forget to call super.layoutChildren()...
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