如何设置javafx TextArea的高度和宽度?

时间:2016-05-26 10:44:29

标签: java javafx-8

TextArea txt = new TextArea();

我可以调用哪种方法来设置此textarea的高度和宽度?

3 个答案:

答案 0 :(得分:2)

setPrefColumnCount()和setPrefRowCount()工作

答案 1 :(得分:2)

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

答案 2 :(得分:0)

更好:

TextArea textArea = new TextArea();
double prefWidth = 1.0
double prefHeight = 1.0
textArea.setPrefSize(prefWidth, prefHeight);