Search code examples
javajava-memidplcdui

how to create textarea in j2me


Below code only showing the textfield, but I want to include textfield and textarea. Need Help

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);

Solution

  • What you call textarea is an lcdui object TextBox; it can not be shown at the same screen as TextField.

    If you're interested, refer to 'lcdui' tag info for more details on why is that (there are links to API reference, tutorials, popular libraries etc).

    For the code snippet you posted, first thing that comes to mind would be to just replace TextBox to TextField, like

            // ...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);