JLabel - criando texto sublinhado

O JLabel aceita tags HTML

 

import javax.swing.*;

 

public class Teste extends JFrame {

 

 public Teste() {

         setSize(200110);

         setDefaultCloseOperation(EXIT_ON_CLOSE);

         JLabel texto1 = new JLabel();

         texto1.setText("<html><u>Sublinhado</u><br><i>Itálico</i><h2>teste</h2></html>");

         add(texto1);

 }

 

 public static void main(String[] args) {

         new Teste().setVisible(true);

 }        

}

 

Tela