Java Swing How to - Change JLabel font








Question

We would like to know how to change JLabel font.

Answer

//w  ww  .ja v a 2 s. c o  m
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main {
  public static void main(String[] args) {
    
    JLabel label = new JLabel("Full Name :", JLabel.LEFT);
    
    label.setFont(new Font("Georgia", Font.PLAIN, 14));
    
    JOptionPane.showMessageDialog(null, label);
    
  }
}