I have a label and when setting the text I want to change line . For instance
String str=\"first line \\n Secondline \";
JLabel label.setText(str);
<
Swing does not uses classical line breaks. Instead, for a reason I never fully understood, it uses HTML 3.2. As a consequence, to have your text correctly displayed, yopu have to rely upon HTML content :
String str= "<html>First line<br>Second line</html>"
However, if you really want to, there are other possibilities ...
Use this string
String str= "<html>First line<br>Second line</html>"