I have mostly tried everything so far, I also read, that the HTML render of Java is really limited, and just can do like HTML 3/2 or something like that. So mostly all modern CSS styles aren't working. Basically I need small icons (10x10px) vertically aligned with text over several rows, and I can't find a working solution. The only workaround I have found is create a table:
<table><tr><td>text</td><td><img></td><td>text</td></tr></table>
This works, but just for single line, if there is a line wrap, it doesn't work obviously anymore.
All other solutions which normally work in a browser don't work in a JTextPane, for example setting style="float: left;" for a table in a div, or just using vertical-align: middle; with the img and div elements.
Is there maybe a "dirty" way to manipulate the getViewFactory of the HTMLEditorKit to return all ImageViews few pixels below where they should be rendered?
This is how you can edit the HTMLFactory. Here I change the InlineView to make me able to strike through it diagonally. Use it for your own purpose.
You just need to set BetterHTMLEditorKit as the EditorKit for your JTextPane.
About how to edit the way your image is rendered, just create a FloatView for instance. The issue is that you will need to edit the way paragraph and text are rendered around the floating image, and so you need to redefine BlockView and InlineView. So it will not be easy work. But if you succeed, don't hesitate to share!
Check the HTMLEditorKit.create method for a better understanding of what is happening during view generation.
Good luck
EDIT: After reading more carefully your question, I realize that you don't want to render a
floatattribute, but just vertical alignment... For this, you havesetAlignmentY. Set it to 0.5 for middle alignment. For JLabel, you might also need to usesetVerticalAlignmentandsetVerticalTextPosition