aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes escape sequence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "escape sequence" Watch "escape sequence" New topic
Author

escape sequence

abrar alvi
Ranch Hand

Joined: Feb 01, 2012
Posts: 66

how do set escape sequence in setText() method???

here is an example code:





Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
wrap the text in html tags and use the
br tag for your new line (all as a single string)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4658
    
    5

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!


luck, db
There are no new questions, but there may be new answers.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: Feb 01, 2012
Posts: 66

thank you all.... i have replaced with backslash.... i will try with your suggestions...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: escape sequence