Question

How can I put each line of the host in the message body? I work with a JTextArea.

String host = InetAddress.getLocalHost().getHostName().toString();
texto_recepcion.setText(host + texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido + "\n");

How it is now:

enter image description here

Was it helpful?

Solution

I resolve my question with append function.

String host = InetAddress.getLocalHost().getHostName().toString();

texto_recepcion.append(host); // ***Use the function append for solve the problem***

texto_recepcion.setText(texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido + "\n");

Thanks a lot

OTHER TIPS

Why don't you add the newline character "\n" to the beginning of the string?

texto_recepcion.setText("\n" + host + texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top