【问题标题】:Align html content(image) of a JEditorPane对齐 JEditorPane 的 html 内容(图像)
【发布时间】:2023-03-07 19:03:01
【问题描述】:

我有一个默认为 450px X 400px 的 JEditorPane,我以这种方式使用 HTML 将其放入 250px X 250px 的图像中:

JEditorPane editorPanePreview = new JEditorPane();
String logosrc = MainWindow.class.getResource("/resources/logo.png").toString();
editorPanePreview.setText("<html><img src='" + logosrc + "' ></img></html>");

图像显示正确,但默认对齐在 JEditorPane 的左上角,我想将它对齐在 JEditorPane 的右下角;有可能吗?

右下角JEditorPane的内容如何对齐?

【问题讨论】:

    标签: java image swing alignment jeditorpane


    【解决方案1】:

    看到这个 http://java-sl.com/tip_center_vertically.html 垂直对齐内容。

    您需要为 HTMLEditorKit 覆盖另一个视图(body 或 BlockView)。

    【讨论】:

      猜你喜欢
      • 2011-09-25
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 2014-02-05
      • 2016-04-15
      • 2019-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多