Why not do something like this?

Qt Code:
  1. connect(serverAddress, SIGNAL(textChanged(const QString &)), this, SLOT(check(const QString &)));
  2. void myClass::check(const QString &str){
  3. button->setEnabled(!str.isEmpty());
  4. }
To copy to clipboard, switch view to plain text mode 
It's C++ code, but it's very simple so you should have no trouble translating it to Java. Oh, and check() has to be a slot, of course.