TextField不动态更新 [英] TextField not updating dynamically

查看:106
本文介绍了TextField不动态更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常简单的代码,其中按钮上的文本被复制到TextField。
代码工作正常,但单击按钮后TextField不会立即更新。
仅在我单击TextField或我拖动表单时不立即按下按钮时更新。
为什么会发生这种情况,这种行为是出乎意料的。
我正在支持LWUIT的诺基亚501仿真器上测试此代码。

this is a really simple code in which text on a button is copied to a TextField. The code works fine but the TextField is not updating instantly on clicking the button. It updates only after i click on the TextField or when i drag the form not on pressing the button instantly. why is this happening,this behavior is unexpected. i am testing this code on a nokia 501 emulator which supports LWUIT.

           a = new Form("CALCULATOR")
                   final TextArea data = new TextArea();
           final Button ab = new Button("Some Value");
           ab.addActionListener(new ActionListener(){

            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub

                data.setText(ab.getText());

            }

           });
           a.addComponent(ab);
           a.addComponent(data);
           a.show();
                   }


推荐答案

在设置文本后textfield重绘它。这可能有效

After setting the text in the textfield repaint it. This may work

  data.setText(ab.getText());
  data.validate(); or data.repaint();

这篇关于TextField不动态更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆