Search This Blog

Showing posts with label JLabel. Show all posts
Showing posts with label JLabel. Show all posts

How to Display Multiple Lines in JLabel

multiple lines of text i JLabel, Java source code. Java code to display multiple lines in JLabel. HTML formatting in JLabel Java.
HTML formatted multiline JLabel
Jlabel is actually intended to show single line of text. But you may sometimes ask how to make JLabel to display multiline text. It is possible for JLabel to show multiple lines of text. JLabel in Java can show HTML formatted text. This ability of JLabel can be used to extend longer text onto next line. The following lines of code is an answer for the questions like 'is there a multi-line JLabel' or 'how to display multiple lines using JLabel. Simply, look at the sample code:
JLabel lbl_Multiline=new JLabel();
lbl_Multiline.setText("<html>This is my long text to display with JLabel....</html>");