用于S40容器的LWUIT中的自动滚动

时间:2013-01-09 12:24:30

标签: scroll lwuit autoscroll

这是我的代码。我希望第20个标签可见,任何人都知道如何完成它。

另一篇帖子Auto Scrolling in LWUIT Container表示componentOfLastContainer.requestFocus(); centerBigContainer.repaint(); 会工作,但似乎不适合我。我需要你的帮助,谢谢

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


}

1 个答案:

答案 0 :(得分:0)

我猜测,如果请求焦点对您不起作用,则它与您在那里的文本区域相关。我对诺基亚前叉没什么帮助,但这应该适用于Codename One