Reputation: 225
when i use this code it does not work; the text does not become bold. Why?
label1 = new JLabel();
label1.setText("Welcome, <html><strong>Hussein</strong></html>.");
Upvotes: 0
Views: 1217
Reputation: 2516
You forgot to add body tag ,Try This :
label1 = new JLabel();
label1.setText("<html><body>Welcome ,<strong> Hussein</strong></body></html>");
Upvotes: 0
Reputation: 2615
try this:
JLabel label = new JLabel("<html><yourTagHere><yourOtherTagHere>this is your text</yourOtherTagHere></yourTagHere></html>");
Upvotes: 0
Reputation: 1121
Why are you mixing html and java. tag is in html. This is how you do in java
label = new JLabel("A label");
label.setFont(new Font("Serif", Font.BOLD, 14));
Upvotes: -1