Search code examples
scrolllwuitautoscroll

Auto Scrolling in LWUIT for S40 Container


Here is my code. I want the 20th Label be visable, anyone knows how to accomplish it.

another post Auto Scrolling in LWUIT Container says componentOfLastContainer.requestFocus(); centerBigContainer.repaint(); will work,but it seems not work for me. I need Your help ,thanks

public class TestView extends Form{
private TextArea inputText;
private Container chatScreen = new Container(new BoxLayout(BoxLayout.Y_AXIS));

public TestView () {
    super("test", null);
    setupUI();
        }

void setupUI() {
    setLayout(new BorderLayout());
    setScrollable(false);
    chatScreen.setScrollableY(true);
    addComponent(BorderLayout.CENTER, chatScreen);
    inputText = new TextArea(2, this);
    inputText.setGrowByContent(true);
    inputText.setMaxSize(1000);
    Container sendContainer = new Container(new BorderLayout());
    sendContainer.addComponent(BorderLayout.CENTER, inputText);
    addComponent(BorderLayout.SOUTH, sendContainer);


    for (int i = 0; i < 20; i++) {
        Label l = new Label("sdjfksjfksjd" + i);
        c = new Container();
        c.addComponent(l );
        chatScreen.addComponent(c);
    }

  c.requestFocus();

  chatScreen.repaint();


    Display.getInstance().callSerially(new Runnable(){

            public void run() {
                  c.requestFocus();

                 chatScreen.repaint();
            }
        });


}

Solution

  • I'm guessing that if request focus isn't working for you its related to the text area you have there. I can't really help much with the Nokia fork but this should work on Codename One.