Is it Bad Practice to use HTML Styling in Java Swing Elements?

Viewed 947

It is considered bad practice to style Swing elements using HTML?

As an example, if I want to make a label bigger and red just once, I have two options:

Either using API calls:

JLabel label = new JLabel("This is a title");  
label.setFont(label.getFont().deriveFont(18));  
label.setForeground(Color.red);

Or by using HTML:

JLabel label = new JLabel("<html><font size='4' color='#ff0000'>This is a title");

In addition, the HTML way allows me to emphasise one word instead of a whole label, and other such uses.

What are the drawbacks of using HTML? Is it more expensive? And is formatting not guaranteed on all JREs?

2 Answers
Related