Java me 在LWUIT中,如何以编程方式设置;文本区域';s卷轴“;向下移动后,返回顶部?

Java me 在LWUIT中,如何以编程方式设置;文本区域';s卷轴“;向下移动后,返回顶部?,java-me,scroll,scrollbar,lwuit,lwuit-textarea,Java Me,Scroll,Scrollbar,Lwuit,Lwuit Textarea,使用LWUIT,我有一个表单,包含两个组件:一个只读文本区域和一个按钮: 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 ActionLis

使用LWUIT,我有一个
表单
,包含两个组件:一个只读
文本区域
和一个
按钮

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

文本区域
有一个
滚动条
,因为它包含一个长的
字符串
,当用户向下移动
时,
文本区域
滚动条
向下移动,直到到达
字符串
的末尾,然后,
按钮
聚焦,将
文本区域
滚动条
留在
文本区域
的末尾

我想要的是,当点击
按钮时,滚动条会返回到
文本区
顶部
的原始状态,而不是
文本区
底部
我如何才能做到这一点?

这是为感兴趣的人提供的解决方案
通过使用自定义文本区域

public class CustomTextArea extends TextArea {
    public TextAreaScrollControlled(String text) {
        super(text);
    }

    public void resetScrollBackToTop() {
        setScrollY(0);
    }
}
那么代码如下(而不是问题中的代码):


PS.“文本”应为最终文本或课堂成员;)

这篇文章可能会帮助你解决这个问题,谢谢!我会为任何有同样问题的人发布答案,以便在以后的搜索中发布。太棒了!我会努力做到的!scrollRectToVisible(0,0,10,10)也应该可以工作,而且我记得它是公开的
CustomTextArea text = new CustomTextArea("blah blah blah blah blah blah ...");
text.setEditable(false);
addComponent(text);

Button button = new Button("Press Me !");
button.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent evt) {
          text.resetScrollBackToTop(); // SOLUTION
     }
});
form.addComponent(button);