{"id":597,"date":"2012-11-14T06:52:19","date_gmt":"2012-11-14T04:52:19","guid":{"rendered":"http:\/\/www.pellissier.co.za\/hermien\/?p=597"},"modified":"2012-11-14T06:52:19","modified_gmt":"2012-11-14T04:52:19","slug":"hiding-tabs-for-undocked-topcomponents","status":"publish","type":"post","link":"https:\/\/www.pellissier.co.za\/hermien\/?p=597","title":{"rendered":"Hiding Tabs for Undocked TopComponents"},"content":{"rendered":"<p>In our NetBeans Platform application, we have a TopComponent that needs to always be opened in an undocked and maximised state. When I manually undocked the window the first time though, I immediately noticed that the single tab that appears in the window just looks really silly. <\/p>\n<p><a href=\"http:\/\/www.pellissier.co.za\/h\/wp-content\/uploads\/sites\/2\/2012\/11\/pesky-tab.png\"><img loading=\"lazy\" src=\"http:\/\/www.pellissier.co.za\/h\/wp-content\/uploads\/sites\/2\/2012\/11\/pesky-tab.png\" alt=\"\" title=\"pesky-tab\" width=\"208\" height=\"81\" class=\"aligncenter size-full wp-image-598\" \/><\/a><\/p>\n<p>So I set out to get the window to automatically undock as well as to remove that annoying tab.<\/p>\n<p>In order to get the window to be opened as undocked, I needed to define a new separated mode to dock the window into. See section 3 of Geertjan\u2019s <a href=\"http:\/\/netbeans.dzone.com\/news\/secrets-netbeans-window-system\">Secrets of the NetBeans Window System<\/a> post for more details about the mode. Note that the mode\u2019s kind property needs to be editor for the whole thing to work.<\/p>\n<p>I called my new mode floater, and the code that opens and maximises the window now looked like this:<\/p>\n<p>[java]Mode floater = WindowManager.getDefault().findMode(&#8220;floater&#8221;);<br \/>\nTopComponent tc =<br \/>\n        WindowManager.getDefault().findTopComponent(&#8220;test2TopComponent&#8221;);<br \/>\nfloater.dockInto(tc);<br \/>\ntc.open();<br \/>\nJFrame root = (JFrame) SwingUtilities.getRoot(tc);<br \/>\nroot.setExtendedState(root.getExtendedState() | Frame.MAXIMIZED_BOTH);[\/java]<\/p>\n<p>But the pesky tab was of course still there, so I needed more information. And in my search I came across another of Geertjan\u2019s articles &#8211; <a href=\"https:\/\/blogs.oracle.com\/geertjan\/entry\/farewell_to_space_consuming_weird\">Farewell to Space Consuming Weird Tabs<\/a>. I did, however, not want to remove all the tabs from the whole application, just that particular one. So after creating the class test.NoTabsTabDisplayerUI as Geertjan describes, I had to find the right spot to set the UIManager property. And as it turns out, I just had to set the property before opening the window, and reset it to its previous value after. So the code finally is:<\/p>\n<p>[java]Mode floater = WindowManager.getDefault().findMode(&#8220;floater&#8221;);<br \/>\nObject oldTabDisplayer = UIManager.get(&#8220;EditorTabDisplayerUI&#8221;);<br \/>\nUIManager.put(&#8220;EditorTabDisplayerUI&#8221;, &#8220;test.NoTabsTabDisplayerUI&#8221;);<br \/>\nTopComponent tc =<br \/>\n        WindowManager.getDefault().findTopComponent(&#8220;test2TopComponent&#8221;);<br \/>\nfloater.dockInto(tc);<br \/>\ntc.open();<br \/>\nJFrame root = (JFrame) SwingUtilities.getRoot(tc);<br \/>\nroot.setExtendedState(root.getExtendedState() | Frame.MAXIMIZED_BOTH);<br \/>\nUIManager.put(&#8220;EditorTabDisplayerUI&#8221;, oldTabDisplayer);[\/java]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our NetBeans Platform application, we have a TopComponent that needs to always be opened in an undocked and maximised state. When I manually undocked the window the first time though, I immediately noticed that the single tab that appears in the window just looks really silly. So I set out to get the window &#8230; <a title=\"Hiding Tabs for Undocked TopComponents\" class=\"read-more\" href=\"https:\/\/www.pellissier.co.za\/hermien\/?p=597\" aria-label=\"More on Hiding Tabs for Undocked TopComponents\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[3,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1v8WL-9D","_links":{"self":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/597"}],"collection":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=597"}],"version-history":[{"count":0,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/597\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=597"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}