In short: setSize(..)
doesn’t work at all, you’ll need setPreferredSize(..)
followed by revalidate()
if (changed) { //Update client's preferred size because //the area taken up by the graphics has //gotten larger or smaller (if cleared). drawingArea.setPreferredSize(/* the new size */); //Let the scroll pane know to update itself //and its scroll bars. drawingArea.revalidate(); }
Resources:
http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#update