Newline in JLabel
Surround the string with <html></html> and break the lines with <br/>. JLabel l = new JLabel(“<html>Hello World!<br/>blahblahblah</html>”, SwingConstants.CENTER);
Surround the string with <html></html> and break the lines with <br/>. JLabel l = new JLabel(“<html>Hello World!<br/>blahblahblah</html>”, SwingConstants.CENTER);
Use label.setOpaque(true); Otherwise the background is not painted, since the default of opaque is false for JLabel. From the JavaDocs: If true the component paints every pixel within its bounds. Otherwise, the component may not paint some or all of its pixels, allowing the underlying pixels to show through. For more information, read the Java … Read more