Learn Swing JLabel with Easy Example

In this tutorial you will learn:

1. How to Use JLabel in Swing?
2. How to set image in JLabel?
3. Programming Example

JLabel is used for displaying unselectable texts and images. It is widely used for displaying label text on swing form. In this article I will show you how to use JLabel in Swing Application.

Programming Example

In this example I will show you to display text and image both.



Consider the following codes


1. You can use HTML Tag in JLabel for additional customization like changing font-weight, font-style, line-break etc.

2. Set Picture in Label

3. You can change JLabel appearance like this

4. Set Frame Layout with 2 row and 1 column and Set Frame Size like this.


In this chapter you learned how to use JLabel in Swing for displaying text and image icon. You also learned to change appearance of JLabel. In the next chapter you will learn JTextField, JPasswordField and JTextArea in Swing.

Leave a Reply

Your email address will not be published. Required fields are marked *