I’m creating a chat program, similar to IRC. With my client though, I have the problem that when text is added to a JTextPane (using a GridBagLayout), it resizes instead of wordwraps. Well, it actually will wordwrap eventually, but it shouldn’t be resizing. Here is what I mean:

I could set the JTextPane dimension to an exact number, but I want the user to be able to resize the window, and the parts inside as needed. How can I get to put as much text in without it resizing?
I ended up fixing it by adding setting it into a JScrollPand and using .setPreferredSize().