? JScrollPane - how to grow the scrollpane ?
843806Nov 13 2008 — edited Nov 13 2008I want to make a timeline tool which will be horizontally scrollable. As events are added I want to be able to scroll farther. I figure there are a couple of ways to do this: Java2D override of the paintComponent() and creating my own actions that will draw the region I want to see, or I use a JScrollPane and let swing take care of scrolling for me.
This second option is what I am trying to prototype right now but I can't figure out how to make the scrollpane to increase in size as I draw more things on the canvas - I'm still overriding the paintComponent() to draw things on a JPanel which I add to the JScrollPane.
When you add a text pane to the JScrollPane and type more text in it, it grows and the scroll bars adjust themselves, but I'm not sure how to handle it when I use a JPanel that has stuff drawn on it. Is my only option to recalculate the size of the stuff I draw in the Panel and tell the scroll pane to readjust its viewport or something like this?
Thanks in advance.