harsha
harsha

Reputation:

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.

Upvotes: 1

Views: 5629

Answers (3)

David Billskog
David Billskog

Reputation: 41

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.

Upvotes: 1

OscarRyz
OscarRyz

Reputation: 199195

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 ;)

Upvotes: 4

Sophie Alpert
Sophie Alpert

Reputation: 143104

Put a \n in the string.

Like this:

String twoLineString = "first line\nsecond line";

Upvotes: 1

Related Questions