• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

escape sequence

 
abrar alvi
Ranch Hand
Posts: 66
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do set escape sequence in setText() method???

here is an example code:





 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wrap the text in html tags and use the
br tag for your new line (all as a single string)
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, the character for escape sequences in Java Strings is the backslash, not the forward slash. But the newline sequence will only be interpreted by text components that inherently support multiline text, and that doesn't include JButton.

Try using HTML with a <BR> tag.

edit Yeah, 5 seconds too late!
edit2: But luckily not another 29 seconds later!
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if Swing elements recognize the backslash escape sequences, but if they do, you need to use a backslash, not a forward slash.

\n, not /n.
 
abrar alvi
Ranch Hand
Posts: 66
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all.... i have replaced with backslash.... i will try with your suggestions...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic