{"id":521,"date":"2009-11-07T15:46:29","date_gmt":"2009-11-07T13:46:29","guid":{"rendered":"http:\/\/raftaman.net\/?p=521"},"modified":"2021-05-15T11:46:41","modified_gmt":"2021-05-15T09:46:41","slug":"dynamically-changing-the-clients-size-of-a-jscrollpane","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=521","title":{"rendered":"Dynamically Changing the Size of a JScrollPane&#8217;s Client"},"content":{"rendered":"<p>In short: <code>setSize(..)<\/code> doesn&#8217;t work at all, you&#8217;ll need <code>setPreferredSize(..)<\/code> followed by <code>revalidate()<\/code><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nif (changed) {\r\n    \/\/Update client's preferred size because\r\n    \/\/the area taken up by the graphics has\r\n    \/\/gotten larger or smaller (if cleared).\r\n    drawingArea.setPreferredSize(\/* the new size *\/);\r\n\r\n    \/\/Let the scroll pane know to update itself\r\n    \/\/and its scroll bars.\r\n    drawingArea.revalidate();\r\n}\r\n<\/pre>\n<p>Resources:<br \/>\n<a href=\"http:\/\/java.sun.com\/docs\/books\/tutorial\/uiswing\/components\/scrollpane.html#update\">http:\/\/java.sun.com\/docs\/books\/tutorial\/uiswing\/components\/scrollpane.html#update<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In short: setSize(..) doesn&#8217;t work at all, you&#8217;ll need setPreferredSize(..) followed by revalidate() if (changed) { \/\/Update client&#8217;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<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4],"class_list":["post-521","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-java"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=521"}],"version-history":[{"count":7,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/521\/revisions"}],"predecessor-version":[{"id":2690,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/521\/revisions\/2690"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}