如何在j2me中创建textarea

时间:2012-05-15 16:18:34

标签: java java-me midp lcdui

下面的代码只显示文本字段,但我想包含textfield和textarea。需要帮助

form1 = new Form("Mobile"); 
tb2 = new TextField("To: ", "", 30, TextField.ANY);
            TextBox tb3 = new TextBox("Message: ", "", 256, TextField.ANY);
            form1.append(tb2);
           // form1.append(tb3);
            form1.addCommand(submitCommand);
            display.setCurrent(tb3);
            display.setCurrent(form1);

2 个答案:

答案 0 :(得分:3)

你所谓的 textarea 是一个lcdui对象TextBox;它无法在与TextField相同的屏幕上显示。

如果您有兴趣,请参阅'lcdui' tag info了解更多详细信息(有API参考,教程,热门图书馆等链接)。

对于您发布的代码段,首先想到的是将TextBox替换为TextField,例如

        // ...initialization of Form and tb2
        TextField tb3 = new TextField("Message: ", "", 256, TextField.ANY);
        // above, TextBox has been replaced with TextField
        form1.append(tb3); // show "Message" textfield above "Mobile"
        form1.append(tb2);
        form1.addCommand(submitCommand);
        display.setCurrent(form1);

答案 1 :(得分:1)

J2ME中没有TextArea这样的东西。您可以使用TextField [s]或TextBox显示Form,因为TextBox是可显示的。您一次只能显示一个Displayable。

相关问题