question: public void run ( ) { int rc = - 1 ; String ipAddr = ( String ) ipAddress . getSelectedItem ( ) ; String portNum = ( String ) port . getSelectedItem ( ) ; String connStr = "" ; try { if ( ipAddr . indexOf ( "://" ) < 0 ) { connStr = "tcp://" + ipAddr + ":" + portNum ; } else { connStr = ipAddr ; } connect ( connStr , optionsComp . isPersistenceSelected ( ) ) ; updateComboBoxList ( ipAddress , ipAddr ) ; updateComboBoxList ( port , portNum ) ; connected = true ; led . setGreen ( ) ; setConnected ( true ) ; } catch ( NumberFormatException nfe ) { JOptionPane . showMessageDialog ( frame , "Invalid port number !" , "MQTT Connect Exception" , JOptionPane . ERROR_MESSAGE ) ; } catch ( MqttException mqe ) { setTitleText ( "MQTT connect failed !" ) ; Throwable e = mqe . getCause ( ) ; String msg = "" ; if ( e == null ) { e = mqe ; } else if ( mqe . getMessage ( ) != null ) { msg += mqe . getMessage ( ) + "\n" ; } msg += e ; JOptionPane . showMessageDialog ( frame , msg , "MQTT Connect Exception" , JOptionPane . ERROR_MESSAGE ) ; e . printStackTrace ( ) ; } catch ( Exception ex ) { setTitleText ( "MQTT connect failed !" ) ; JOptionPane . showMessageDialog ( frame , ex , "MQTT Connect Exception" , JOptionPane . ERROR_MESSAGE ) ; ex . printStackTrace ( ) ; } if ( ! connected ) { led . setRed ( ) ; setConnected ( false ) ; } synchronized ( this ) { if ( connected ) { writeLogln ( "WebSphere MQ Telemetry transport connected to " + mqtt . getServerURI ( ) ) ; } else { writeLogln ( "ERROR:WebSphere MQ Telemetry transport failed to connect to " + connStr ) ; } } }
target:  Invoked by actionPerformed when connect is pressed.  This allows actionPerformed to return and paint the window. This thread then does the MQTT connect to the broker.<BR> This method also ensures that the LED colour is set correctly and writes an entry to the history dialog if it is open.