Disabling HTML support in a JLabel

Sometimes, it may be necessary to display html tags inside a JLabel. If the text of an HTML enabled JComponent like JLabel starts with then this text will be rendered as HTML. To prevent this rendering from happening, set the clientproperty html of that JLabel to null.


import javax.swing.plaf.basic.*;
import java.awt.event.*;
import java.awt.font.*; 
import javax.swing.*;
import java.util.*;
import java.text.*;
import java.awt.*;
public class Main extends JFrame {
   public Main() {
      getContentPane().setLayout(new FlowLayout());
      final JLabel label = new JLabel("<html><h1>Test disable html</h1></html>");
      label.putClientProperty("html", null);
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
   public static void main(String[] args) {
      (new Main()).show();