File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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

Joined: May 03, 2008
Posts: 5115

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

Joined: Jan 03, 2004
Posts: 6109

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:
subject: escape sequence
jQuery in Action, 3rd edition