-
Bug
-
Resolution: Incomplete
-
P4
-
None
-
8u144
-
x86
-
windows_10
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Versión 10.0.10586]
A DESCRIPTION OF THE PROBLEM :
If the look and feel is set to Windows or WindowsClassic, my JLabel with HTML text containing <u> (underline) tags show no underline. With default (no look and feel explictly set) or Nimbus it is fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
try {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
//UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
JLabel howToUpdate = new JLabel();
howToUpdate.setForeground(Color.BLUE);
howToUpdate.setText("<html><u>To my blog</u>");
With these code the underline of the label should be visible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I see lines under my label.
ACTUAL -
With neither L&F the line is shown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.font.TextAttribute;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
public class JLabelWithoutUnderline extends JDialog {
public JLabelWithoutUnderline () {
begin();
}
private void begin() {
try {
UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLayout(new BorderLayout());
JLabel text = new JLabel("<html><u>Some text</u>");
text.setBounds(0, 0, 100, 30);
add(text, BorderLayout.CENTER);
pack();
setBounds(0, 0, 500, 400);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JLabelWithoutUnderline frame = new JLabelWithoutUnderline ();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround. I can set font attributes, but what if I only want to underline a part of the text in a JLabel?
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Versión 10.0.10586]
A DESCRIPTION OF THE PROBLEM :
If the look and feel is set to Windows or WindowsClassic, my JLabel with HTML text containing <u> (underline) tags show no underline. With default (no look and feel explictly set) or Nimbus it is fine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
try {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
//UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
JLabel howToUpdate = new JLabel();
howToUpdate.setForeground(Color.BLUE);
howToUpdate.setText("<html><u>To my blog</u>");
With these code the underline of the label should be visible.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I see lines under my label.
ACTUAL -
With neither L&F the line is shown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.font.TextAttribute;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
public class JLabelWithoutUnderline extends JDialog {
public JLabelWithoutUnderline () {
begin();
}
private void begin() {
try {
UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLayout(new BorderLayout());
JLabel text = new JLabel("<html><u>Some text</u>");
text.setBounds(0, 0, 100, 30);
add(text, BorderLayout.CENTER);
pack();
setBounds(0, 0, 500, 400);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JLabelWithoutUnderline frame = new JLabelWithoutUnderline ();
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround. I can set font attributes, but what if I only want to underline a part of the text in a JLabel?