Search code examples
lwuitcodenameone

setting appearance of radiobutton as textarea in codename one


I am building an app using codename one

I have a radiobutton with a very long text.

When i focus on this radio button , the text of that radio button starts scrolling.

What I wish to do is show all the text associated with the radiobutton on the screen.

So i tried radiotbutton.setUIID("TextArea");

But with this, only the appearance of the radiobutton changes. THe radio button's text does not spill over to multiple lines.

I want to show the radio button's text all at once (no matter how long it is) . How do i do it?


Solution

  • MultiButton has a radio button mode but you need to know the number of lines in advance.

    The solution to this is something like:

    RadioButton r = new RadioButton();
    Container c = new Container(new BoxLayout(new BoxLayout.X_AXIS));
    c.addComponent(r);
    TextArea radioText = new TextArea("Long text for radio button");
    radioText.setEditable(false);
    c.addComponent(radioText);
    radioText.setUIID("RadioButton");
    c.setLeadComponent(r);
    

    You can do this entire thing in the GUI builder which supports lead component as well.