1

I'm using a String builder to display my data in a FlowPanel( parsed JSON data) and im trying to display each Object on a new line. I have tried using "\n", "\r\n", etc and still no joy. Any ideas?

StringBuilder builder = new StringBuilder("** TODAYS WEATHER** <br/>");
                    builder.append(jsonArray.get(0).isObject().get("Town").isString().stringValue()).append(" ");
                    builder.append(jsonArray.get(0).isObject().get("Weather").isString().stringValue()).append(",");
                    builder.append("<br/>");
                    label.setText(builder.toString()+ "</br>");
eire1994
  • 29
  • 7

1 Answers1

0

use environment new line

StringBuilder sb = new StringBuilder();
sb.AppendFormat("text {0} more text", Environment.NewLine);
string s = sb.ToString();
Shachaf.Gortler
  • 5,655
  • 14
  • 43
  • 71
  • Thanks for your answer but it i'm still getting an error. "New Line can not be resolved or is not a field". I'm using eclipse, and it does not seem to have the required import for the function? – eire1994 Apr 29 '16 at 20:58
  • try this , System.lineSeparator(). from here : http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#lineSeparator%28%29 – Shachaf.Gortler Apr 29 '16 at 21:11
  • Ah, researched a bit more into it and realised that you cannot implement a new line when using Labels. So i changed it to a TextArea and all is working perfect now. Thank you so much for your time ! – eire1994 Apr 29 '16 at 23:07