Natural text wrapping inside of GridBagLayout

Hi,

 
I'm just ramping up on Swing and I'm running into some problematic layout issues relating to to textual content in JTextPane failing to wrap.
 
I've had some success adding a JTextPane to a JPanel with a layout of BorderLayout or CardLayout... but GridBagLayout seems to be giving me trouble. Regardless of the constraints used or if I use an enclosing panel, I just get a long line that overflows the available space. The only success I've had is to set a preferred size that's a minimal width (which causes natural wrapping). The downside is that I need to also provide a preferred height and that causes either extra space or vertical clipping.
 
I can provide some code samples but I've run through any of a number of structures attempting to get the correct layout so there isn't anything particularly representative.
 
Any suggestions or pointers would be more than appreciated, thanks!
1 comment
Comment actions Permalink

Correction, wrapping appears to work if I remove the enclosing JBScrollPane. Some general guidance on when wrapping should and shouldn't work would be fantastic but this request may be premature until I can nail down the specific set of circumstances that consistently fails to wrap properly.

0

Please sign in to leave a comment.