java TextBox 中的新行 (JavaFX 2.0)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6723506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
new line in TextBox (JavaFX 2.0)
提问by Martynas
I'm trying to create TextBox
with JavaFX 2.0
.
My source is following:
我正在尝试TextBox
使用JavaFX 2.0
. 我的来源如下:
TextBox textBox = new TextBox();
textBox.setPrefSize(150, 600);
textBox.setText("Hello\n world!");
Result is:
结果是:
How could I create new line in TextBox
?
我怎么能在 中创建新行TextBox
?
回答by pmoule
Creating a multilined TextBox is a JavaFX 1.3 feature. In JavaFX 2.0 you have to use a TextArea.
创建多行文本框是 JavaFX 1.3 的一项功能。在 JavaFX 2.0 中,您必须使用 TextArea。
TextArea textArea = new TextArea();
textArea.setPrefRowCount(2);
textArea.setText("Hello\nworld!");
The JavaFX UI Controlstutorial does not mention the TextArea control. Maybe they missed something. As you can see in this JavaFX 1.3 TextBoxtutorial the TextBox had a 'multiline' and a 'lines' property. JavaFX 1.3 did not have a TextArea.
在JavaFX的UI控件教程没有提到TextArea控件。也许他们错过了什么。正如您在此JavaFX 1.3 TextBox教程中所见,TextBox 具有“多行”和“行”属性。JavaFX 1.3 没有 TextArea。