TextBox中的新行(JavaFX 2.0) [英] new line in TextBox (JavaFX 2.0)

查看:141
本文介绍了TextBox中的新行(JavaFX 2.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JavaFX 2.0 创建 TextBox
我的来源如下:

I'm trying to create TextBox with JavaFX 2.0. My source is following:

TextBox textBox = new TextBox();
textBox.setPrefSize(150, 600);
textBox.setText("Hello\n world!");

结果是:

如何在<\\ n>中创建新行? code> TextBox ?

推荐答案

创建多行TextBox是JavaFX 1.3的一项功能。在JavaFX 2.0中,您必须使用TextArea。

Creating a multilined TextBox is a JavaFX 1.3 feature. In JavaFX 2.0 you have to use a TextArea.

TextArea textArea = new TextArea();
textArea.setPrefRowCount(2);            
textArea.setText("Hello\nworld!");

JavaFX UI控件教程未提及TextArea控件。也许他们错过了什么。正如您在 JavaFX 1.3 TextBox 教程中所看到的那样,TextBox具有'多行'和'行'属性。 JavaFX 1.3没有TextArea。

The JavaFX UI Controls tutorial does not mention the TextArea control. Maybe they missed something. As you can see in this JavaFX 1.3 TextBox tutorial the TextBox had a 'multiline' and a 'lines' property. JavaFX 1.3 did not have a TextArea.

这篇关于TextBox中的新行(JavaFX 2.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆