How to wrap text around components in a JTextPane?

前端 未结 1 760
心在旅途
心在旅途 2021-01-18 15:45

I don\'t understand the wrapping behavior in a JTextPane. If I insert a short text, then a JComponent and then again the short text I can see the inserted stuff in one line

相关标签:
1条回答
  • 2021-01-18 16:33

    That strange behavior seems to happen due to the content type you set. Try removing this line:

    textPane.setContentType ( "text/html" );
    

    and you will see that everything works fine after that. I am not sure why it happens - might be either some rendering bug or just an intended behavior.

    P.S. I don't think that using Swing components inside text pane (whatever the reason is) is a good option. But that is just my opinion...

    0 讨论(0)
提交回复
热议问题