Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在lwuit(J2ME)中显示多行文本区域?_Java_Java Me_Lwuit - Fatal编程技术网

Java 如何在lwuit(J2ME)中显示多行文本区域?

Java 如何在lwuit(J2ME)中显示多行文本区域?,java,java-me,lwuit,Java,Java Me,Lwuit,我已经用语句创建了一个TextArea quest1Label = new TextArea(); 我正在使用文本区域显示标签。。。。所以我使用下面的函数来设置它的属性 private void setTextAreaProperty(TextArea textArea) { String textStr = textArea.getText(); if (textArea.getStyle().getFont().stringWidth(textStr) > (widt

我已经用语句创建了一个
TextArea

quest1Label = new TextArea();
我正在使用
文本区域
显示
标签
。。。。所以我使用下面的函数来设置它的属性

private void setTextAreaProperty(TextArea textArea) {
    String textStr = textArea.getText();
    if (textArea.getStyle().getFont().stringWidth(textStr) > (width - 25)) {
        textArea.setSingleLineTextArea(false);
    } else {
        textArea.setSingleLineTextArea(true);
        textArea.setPreferredW(width);
    }
    textArea.setBorderPainted(false);
    textArea.setFocusable(false);
    textArea.setStyle(getPreviewStyle());
}
其中width=Display.getInstance().getDisplayWidth() 我的问题是,多达两行的标签工作正常,但。。。。如果文本更大,则不会转到第三行。 任何有关这方面的帮助都将不胜感激

提前谢谢,…。

您试过了吗?也许默认的行数是2,并且增长不会超过2


注意。

您需要像这样使用
TextArea
构造函数
新的TextArea(1,20)
,这样可以更有效地“增长”版面


原因主要是历史原因,LWUIT对
Texarea
有一个3列默认值,这允许
Texarea
很好地收缩,但在增长时会变差。增长/收缩的复杂性源于这样一个事实:布局可以深度嵌套和滚动,因此可用空间与所需空间的计算变得递归,并且在某些难以检测的点无法解决(无限递归)

@Bharath:plz请查看已编辑的代码。。。。