
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to create JLabel to hold multiline of text using HTML in Java?
To hold multiline of text, set HTML under JLabel −
JLabel = new JLabel("<html><strong>" + "Line1<br>Line2</strong></html>",JLabel.LEFT);
The above will create multiline text in the JLabel −
Line1 Line2
The following is an example to create JLabel to hold multiline of text −
Example
import java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Example"); JLabel label; label = new JLabel("" + "Line1 Line2",JLabel.LEFT); label.setBounds(100, 100, 100, 30); label.setFont(new Font("Verdana", Font.PLAIN, 13)); frame.add(label); frame.setSize(500,300); frame.setLayout(null); frame.setVisible(true); } }
Output
- Related Articles
- How to change text font for JLabel with HTML in Java?
- How to add line height to multiline text in Text using FabricJS?
- How to align JLabel text vertically top in Java?
- How to create a multiline input control text area in HTML5
- How to add line height to multiline text in IText using FabricJS?
- Java Program to set alignment for text in JLabel
- How to make Ellipsis to multiline text in CSS?
- How can we implement a moving text using a JLabel in Java?
- Java Program to change JLabel text after creation
- How to create teletype text in HTML?
- How to create a JLabel with an image icon in Java?
- How can we rotate a JLabel text in Java?
- How to create sliding text reveal animation using HTML and CSS?
- How to set the text of the JLabel to be right-justified and vertically centered in Java?
- How to add tooltip to JLabel in Java?

Advertisements