views:

76

answers:

2

Hello,

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 navigable, 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

A: 

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.

Carl Smotricz
Thanks a lot for explaining me how wrong this requirement is. I already thought that this requirement is some kind of strange. What we want to achieve is some kind dashboard in front and starting from this you can open any kind of objects/pages in tabs. But yo have to get back to the dashboard as fast as possible and it has to be visible all the time (so the user can go back to "home" w/o destroying the old tabs). What would you do for this problem? The customer wants this "fixed" first tab so badly, and i don't want to give it to him since i see, that he won't be happy with the solution.
Nils Drews
Well, it's beginning to sound more reasonable. You want the **tab** visible all the time, not necessarily the contents of its associated page. And you want the tab not to move around in the order of available/accessible tabs. I have a new suggestion that would meet those requirements and be reasonably aesthetic. (see other answer, soon as I finish posting it)
Carl Smotricz
+1  A: 

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.

Carl Smotricz