class Listener extends Thread { public Listener( ) {} @Override public void run() { String the_response=""; while (ClientFrame.is_listening) { try { the_response=ClientFrame.in.readLine(); ClientFrame.theMessage.setText(the_response); ClientFrame.theMessage.repaint(); } catch (Exception e) { e.printStackTrace(); System.out.println("Exception"); } } } } |
class Listener extends Thread { public Listener( ) {} @Override public void run() { String the_response=""; while (byteClientFrame.is_listening) { try { int length = byteClientFrame.in.readInt(); byte[] the_bytes = new byte[length]; byteClientFrame.in.readFully(the_bytes, 0, length); the_response = new String(the_bytes,"UTF8"); byteClientFrame.theMessage.setText(the_response); byteClientFrame.theMessage.repaint(); } catch (Exception e) { e.printStackTrace(); System.out.println("Exception"); } } } } |