开发者

Any way to force jidetabbedpane to show always the first tab

开发者 https://www.devze.com 2022-12-12 20:11 出处:网络
i have the requirement that i have to display a tabbedpane, but the first tab has to be static. So i tried to use the jidetabbedpane, since it cares about the effect, that all the tabs are listed in a

i have the requirement that i have to display a tabbedpane, but the first tab has to be static. So i tried to use the jidetabbedpane, since it cares about the effect, that all the tabs are listed in a box, it is navig开发者_Python百科able, it can show the desired close operation and so on. But the only thing i am missing is the option: set first component static or fixed.

Any idea to overcome that problem?

Thanks in advance,

Nils Drews


It sounds like the requirement is for some master page to be always quickly accessible although the user is busily creating other tabs. I have a suggestion:

This involves nested JTabbedPanes. As you know, you can place the tabs on all 4 sides of the component. So what I'd do is create a "primary" JTP with just 1 or 2 tabs, the first of which is of course your "main" tab. Then, the second page in that component can be either empty or appear when the user creates his first new "secondary" page. That second page should be a JTP too, probably with tabs placed in a different direction; and all newly created secondary pages would be contained by this "inner" JTP. The user can flip around in the secondary pages, close them and whatever, but the tab for the main page will always be visible outside the borders of the inner JTP.

Then you can fiddle with the details, such as making the tabs of the primary JTP un-closeable. Making them un-moveable should be less of a priority now that that pane has only 2 pages.

Alternatively, you could put your primary and secondary contents on separate pages of a CardLayout and provide a button (or two) to quickly go there (and back). Depending on how your app is laid out, this may need a little less space. You can connect an Action to this button, triggered by an accelerator key... very quick, quite convenient. This might appease your boss/customer.


Yes. Throw away the design that calls for tabbed panes with a fixed first tab: That's simply abusing the component for something it wasn't meant to do.

You could probably prevent tab flipping by attaching a change listener and having it veto or reverse the change; but I'm not going into detail about that because the basic premise is so wrong.


DockingManager has a method called setTabbedPaneCustomizer to help you customize the tabbed pane.

dockingManager.setTabbedPaneCustomizer(new DefaultDockingManager.TabbedPaneCustomizer() { @Override public void customize(JideTabbedPane aTabbedPane) { // figure out if the aTabbedPane is the first pane // getTabCount() == 1 might be a solution? if( isTheFirstPane(aTabbedPane) ) { aTabbedPane.setShowCloseButtonOnSelectedTab(false); } } });

The code block above needs your attention to find out a proper way to find out if the open first pane is the first one. Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消