对齐JEditorPane的html内容(图像)

时间:2011-11-21 17:04:34

标签: java image swing alignment jeditorpane

我有一个JEditorPane,默认为450px X 400px,我用这种方式放入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的内容?

1 个答案:

答案 0 :(得分:2)

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

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