我需要将文本格式化为 HTML。因此,文本被包含在 HTML 标记中,并应用了正确的颜色和对齐方式。颜色设置有效,但“text-align: center;”设置的对齐方式无效。希望在“botlabel”中居中对齐 HTML 文本。
清理和重建项目没有帮助。关于什么可能会覆盖此对齐设置有什么想法吗?任何帮助深表感谢。谢谢。
这是代码
public class TestMessageDialogV2 extends JFrame {
public static void main(String[] args) {
final String html = "<html><h3 style='color: #ff0000; padding: 3px;'>The folder does not exist at this path.</h3>"
+ "<ol style='padding: 3px;'><li><span style='color: #000000;'>a folder path</span></li>"
+ "</ol><h3 style='color: #ff0000;padding: 3px;'>Invalid files selected:</h3>"
+ "<ol style='padding: 3px;'><li>"
+ "<span style='color: #000000;'>The file does not exist at this path.<br />some file</span></li>"
+ "</ol><br clear=all />"
+ "</html>";
UIManager.put("OptionPane.background", Color.WHITE.brighter());
UIManager.put("Panel.background", Color.WHITE.brighter());
SwingUtilities.invokeLater(new …Run Code Online (Sandbox Code Playgroud)