Java JLabel set italic and bold font via HTML

Description

Java JLabel set italic and bold font via HTML

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main extends JFrame {

  public Main() {
    super("Link JLabel with JTextField");

    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JLabel nameLabel = new JLabel("<html>Java <em>demo</em> from <b>demo2s.com</b>.");

    add(nameLabel);/*  ww  w. j av a 2 s.  com*/

  }

  public static void main(String[] args) {
    Main frame = new Main();
    frame.pack();
    frame.setVisible(true);
  }
}



PreviousNext

Related