问题
On a JButton, I want to list information on multiple lines. I tried \n
as a new line character but it didn't work. The following code:
JButton.setText("fnord\nfoo") ;
will be displayed as:
fnordfoo
How do I force a line break?
回答1:
JButton accepts HTML, so for the line break to work use:
JButton.setText("<html>fnord<br />foo</html>");
来源:https://stackoverflow.com/questions/13503280/new-line-n-is-not-working-in-jbutton-settextfnord-nfoo