Hello Everyone,
here is my problem. I want to set part of the text of a JLabel as bold and another part as underlined, and this is how I am trying:
String text = "<html><b>Text one</b> and <u>Text two</html>";
JLabel jLabel1 = new JLabel(text);
But this is not working. Below it is an example ready to be compiled and runned:
import java.awt.*;
import java.util.*;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
String text = "<html><B>Text one</B> and <u>Text two</html>";
JLabel jLabel1 = new JLabel(text);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().add(jLabel1);
jLabel1.setBounds(5,5,150,20);
pack();
setSize(200,200);
}
public static void main(String args[]) {
new Test().setVisible(true);
}
}
Any help is appreciated