我有一个默认为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的内容?

最佳答案

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

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

09-10 06:01
查看更多