You should do long actions in a background thread, not in a button listener, otherwise your UI will seem frozen.
In your listener, set the text to "Connecting" and then launch a thread wrapping your connection stuff. At the end of the runnable, update the text again once the long operation has finished.