JTextPane insert component, faulty vertical alignment

Posted by John O on Stack Overflow See other posts from Stack Overflow or by John O
Published on 2011-06-28T12:52:39Z Indexed on 2011/06/28 16:22 UTC
Read the original article Hit count: 295

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

© Stack Overflow or respective owner

Related posts about java

Related posts about vertical-alignment