Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new line in jlabel  RSS feed

 
vibhas bhingarde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose

String s2=q[u]; //s2="hello my name is john and i stay in usa and i m married"

label.setText(s2.replace("and","\n")) //so that i may get output on new line when "and" is encountered

but thats not so ,it get printed on same line i also tried //n

but when i replace "\n" with any string it works

help me out please



also if i use html to do so how to get value of s2 say :

String htmlLabel = "<html><body> your output is<br>s2<br></body></html>";

because s2 gets its value from q[u] where q[] is array of string which i am retriving from database

 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried "\\n"?
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had the same problem...Solution:
 
vibhas bhingarde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i tried //n tooo!!!
 
vibhas bhingarde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried out with html ,but my problem is value of q[u] is coming from database of datatype string so where ever i wanted a next line in that string i used "+"(or any string character) so that when it gets extracted from database and stored on q[u] "+" can be replaced with any newline character like "\n"


as per your example of html how can i replace "+" with "\n" and store in string s2
 
vibhas bhingarde
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks everyone i have done it;
thank you very much john
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hehe...no prob
Good luck,
cc11rocks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!