Java - Check if JTextField is empty or not

前端 未结 11 1025
北恋
北恋 2020-11-27 17:44

So I got know this is a popular question and already found the solution. But when I try this it doesn\'t work properly.

My JTextField is empty and the button isn\'t

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 18:04

    Try this

    if(name.getText() != null && name.getText().equals(""))
    {
            loginbt.setEnabled(false);
    }
    else
    {
            loginbt.setEnabled(true);
    }
    

提交回复
热议问题