JTextPane insert component, faulty vertical alignment
- by John O
I have a JTextPane, into which I need to insert a JComponent. I'm using JTextPane.insertComponent(Component).
The item is indeed inserted, but the vertical positioning is too high. Instead of having the bottom of the component aligned with the baseline of the current line of text, the component is way above that position, blocking out/over-painting lines of text appearing above.
I have tried calling setAlignmentY(float) with various values, on both the inserted component and the JTextPane, but it doesn't affect the behavior at all.
My guess: there seems to be some state inside my JTextPane or its Document that I need to be changing. But I don't know what it is.
John