I am currently writing an app that contains a JTextArea to output information. It is contained within a JScrollPane, the idea being that once there becomes too much data to display on the text area, the text area automatically grows to fit the available data and the scroll pane kicks in to scroll up and down (horizontal is not an issue as I'm using text wrapping).
Unfortunately I can't seem to find the right combination of preferred size and maximum size on either component to get my app to do this. If I set my preferred size to the starting area and the maximum size to something arbitrarily large, then the text area never grows. Once the data gets to the bottom of the visible area it just stops displaying. I can 'fix' the problem by setting the preferred size to something arbitrarily large, then the text area scrolls as required within the scroll pane, but unfortunately the scroll bars are always there and the area is always scrollable regardless of whether there is any data there to fill it. This makes the app technically functional but ultimately ugly. I am using Gridbag layout, I'm not sure if that's relevant.