resizing a JTextPane dynamically while typing
Hello,
I'm developing an app that calls for maintaining a list of text "segments" that each have a corresponding button. I've created a class called TextSegment (JPanel subclass) that contains a JButton and a JTextPane, and add these dynamically to another JPanel container at the user's request.
Each TextSegment starts off with a fixed height of one line. As the user types, the contents scroll properly, but I'd like to instead automatically grow it vertically (when the user types a CR or the text wraps) so that all the text is visible.
I'm somewhat new to Java/Swing, and am thinking that I should be able to recognize an event where the JTextPane text area grows, and enlarge its container accordingly.
Is this possible? Thanks in advance for any tips or pointers.

