The new line \ n does not work in JButton.setText ("fnord \ nfoo");

On JButton, I want to list information on several lines. I tried \n as a newline character, but that didn't work. The following code:

 JButton.setText("fnord\nfoo") ; 

will display as:

 fnordfoo 

How to force a line break?

+6
source share
1 answer

JButton accepts HTML, so to break the line use:

  JButton.setText("<html>fnord<br />foo</html>"); 
+19
source

All Articles