GWT计时器在独立类中抛出异常

时间:2013-01-28 08:01:29

标签: java gwt timertask gwtquery

我正在使用GWTQuery来检测文本框上的paste事件,然后设置一个小计时器,之后它应该获取粘贴在其中的值。像这样:

        $("#paste").live("paste",new Function() {
            public boolean f(Event e) {
                Timer t = new Timer() {
                    public void run() {
                        String text = paste.getText();
                        String oldtext = box.getText();
                        String oldsel = box.getSelectedText();
                        int oldpos = box.getCursorPos();
                        if (text.matches("^\\d+$")) {
                            box.setText(oldtext.substring(0,oldpos)+text+oldtext.substring(oldpos+oldsel.length(),oldtext.length()));
                            oldpos += text.length();
                        }
                        box.setReadOnly(false);
                        box.setFocus(true);
                        box.setCursorPos(oldpos);
                        paste.setText("");
                    }
                };
                t.schedule(5);

                return true;
            }
        });

当我将它包含在主文件中(声明onModuleLoad的地方,即浏览器中显示的文件时),它就像预期的那样工作。但是,我已将代码分区,将文本框放在自己的包中,并调用initWidget将它们导入主文件中。当我将此代码放在该类中时,我会收到Uncaught exception escaped之类的错误信息,它指向类似 com.google.gwt.sample.myproject.client.Location$3$1.run的内容。谁能告诉我这里有什么问题,我该如何纠正呢?

0 个答案:

没有答案