Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set height and width of JavaFX TextArea?

Tags:

java

javafx-8

TextArea txt = new TextArea();

What method do I call to set the height and width of this TextArea?

like image 434
HashTables Avatar asked Dec 05 '22 18:12

HashTables


2 Answers

TextArea textArea = new TextArea(); //making a TexrArea object
double height = 400; //making a variable called height with a value 400
double width = 300;  //making a variable called height with a value 300

//You can use these methods
textArea.setPrefHeight(height);  //sets height of the TextArea to 400 pixels 
textArea.setPrefWidth(width);    //sets width of the TextArea to 300 pixels
like image 199
Michael Cenzoprano Avatar answered Dec 09 '22 15:12

Michael Cenzoprano


setPrefColumnCount() and setPrefRowCount() worked

like image 32
HashTables Avatar answered Dec 09 '22 13:12

HashTables