使用LWUIT,我有一个Form
由两部分组成:一个只读TextArea
和Button
:在LWUIT中,如何以编程方式将“TextArea的滚动”设置回顶部?
TextArea text = new TextArea("blah blah blah blah blah blah blah blah blah ...");
text.setEditable(false);
form.addComponent(text);
Button button = new Button("Press Me !");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// DESIRED CODE IS HERE ...
}
});
form.addComponent(button);
的TextArea
有Scrollbar
,因为它包含一个长String
,当用户移动DOWN
的TextArea
的Scrollbar
向下移动直至到达String
的末尾,然后Button
得到聚焦,在TextArea
的末尾,离开TextArea
的Scrollbar
。
我想要的是,点击Button
时,滚动条会在TextArea
的Top
中返回到其原始状态,而不是在TextArea
的Bottom
中。 我该怎么做?
这篇文章可能会帮助你http://stackoverflow.com/questions/7484720/lwuit-scrolling – frayab 2012-01-02 16:10:03
这解决了这个问题,谢谢!我会为任何有相同问题的人发布答案,以便为以后的搜索发布 – 2012-01-02 16:39:40