Are you asking how to disable a button and renable it?

It's just: button.setEnabled(boolean)