![]() |
VOOZH | about |
JLabel is a class of java Swing . JLabel is used to display a short string or an image icon. JLabel can display text, image or both . JLabel is only a display of text or image and it cannot get focus . JLabel is inactive to input events such a mouse focus or keyboard focus. By default labels are vertically centered but the user can change the alignment of label.
Constructor of the class are :
Commonly used methods of the class are :
1. Program to create a blank label and add text to it.
Output :
2. Program to create a new label using constructor - JLabel(String s)
Output :
3. Program to create a label and add image to it .
Output :
4. Program to add a image and string to a label
Output :
Note : This programs might not run in an online compiler please use an offline IDE.