GWT检查文本框是否为空 [英] GWT checking if textbox is empty

查看:123
本文介绍了GWT检查文本框是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个学校项目上工作,我试图检查GWT,如果我创建的文本框是空的或不是。我在另一个项目上做了完全相同的事情,并且在那里工作得很好。我在这里和谷歌搜索的答案,但无法找到任何答案。

Im working on a school project and i'm trying to check in GWT if a textbox i create is empty or not. I have done the exact same thing on another project and there it worked fine. i have searched for the answer here and on google but couldn't find any answer.

voornaamTB = new TextBox();
voornaamTB.setText(null);

ok.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (voornaamTB != null) {
                System.out.println("not empty");
            } else {
                System.out.println("empty");
            }
        }
    });


推荐答案

类似于:

Something like:

if(!voornaamTB.getText().isEmpty()) { ...

会起作用。您目前正在测试以查看TextBox本身是否为null,而不是您在第一行初始化它。

will work. You're currently testing to see whether the TextBox itself is null, which it isn't as you initialized it on the first line.

您可能不需要setText(null)立即创建它。

You probably don't need the setText(null) after immediately creating it.

这篇关于GWT检查文本框是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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