【问题标题】:JEditorPane HTML renderingJEdi​​torPane HTML 渲染
【发布时间】:2011-06-06 15:19:23
【问题描述】:

我正在使用 JEditPane 呈现包含链接的 HTML 文本,并使链接可点击。我已经设法做到了,但是文本和链接以丑陋的字体和颜色、默认的蓝色下划线链接等显示。有没有办法在不编辑内部 HTML 的情况下更改 JEditPane 的默认行为?

感谢帮助 谢谢

【问题讨论】:

    标签: java html swing jeditorpane


    【解决方案1】:

    尝试添加 CSS 样式,如下所示:

    JEditorPane jEditorPane = new JEditorPane();
    HTMLEditorKit kit = new HTMLEditorKit();
    StyleSheet styleSheet = kit.getStyleSheet();
    styleSheet.addRule("A {color:red}"); //change links to red
    jEditorPane.setEditorKit(kit);
    

    【讨论】:

    • 太棒了 .. 非常感谢... 只是一个小问题 .. 现在我的其他文本没有用 HTML 标签包裹 .. 我怎样才能改变它的字体呢?
    猜你喜欢
    • 2012-07-29
    • 2011-08-20
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    • 2012-03-14
    • 2011-05-07
    • 2014-06-30
    • 2013-04-14
    相关资源
    最近更新 更多