简体   繁体   中英

Newline character insertion in Java

How can I insert a newline character in a Java applet program if I am using "label" instead of System.out.println() ?

Thanks in advance.

JLabel?

If you're using JLabel, you can use basic HTML in it

Try the following:

<html>Text<br>more text</html>

See this other answer

And upvote it too;)

Put a \n in the string.

Like this:

String twoLineString = "first line\nsecond line";

I am not sure what you are asking for but you can use System.getProperty("line.separator"); to get the line separator for your operating system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM