From: Andreas Leitgeb on 15 Sep 2009 12:35 I've got difficulties with JSplitPane: Some dialog consist of four parts (vertically), with sliders between each. That was created by a colleague with netbean's form-editor, and works almost ok. There is one master-JSplitPane, and two inner JSplitPanes and inside that are the actual components. Now, "they" want a special behaviour: if the bottom-most component is hidden (with slider's arrow-buttons on windows), then the other three components should all grow to fill the available screen-estate, and if the last one is made visible again, then all the other ones should shrink equally a little to make room for the last one. I'm a bit at loss. It seems to do a lot already on closing/reopening that last part. Things that I can only assume is implemented in the JSplitPane (as I didn't implement it myself; perhaps that goes auto- magically based on Components' preferred- and minimum sizes), but it doesn't propagate that extra space to the upper sibling in the master JSplitPane. I.e.: only the upper component of the lower inner JSplitPane gets all the extra space. How would I better arrange or tweak those SplitPanes such that size- propagation among the other Components works more "natural"? I tried to become friends with netbeans, but netbeans obviously refused my friends-request and misunderstood all my attempts at dragging components around in the form-editor to the point that even repeated "undo" didn't restore the old state, but only exiting and restarting netbeans did. In the end, if I have to restructure the hierachy, I'll probably have to hand-edit the .form file as well for it to remain consistent with the .java, in case future colleagues will want to edit that dialog after me and to whom netbeans is more cooperative. (freshly installed netbeans 6.1.7 here)
From: markspace on 15 Sep 2009 14:37 Andreas Leitgeb wrote: > How would I better arrange or tweak those SplitPanes such that size- > propagation among the other Components works more "natural"? I think it depends on the type of LayoutManager your component uses. Are you allowed to post the code you colleague wrote? Is NetBeans using its default layout manager (GroupLayout, I think)? > > I tried to become friends with netbeans, but netbeans obviously refused > my friends-request and misunderstood all my attempts at dragging This is funny stuff. Old timers trick: You have to write a complicated procedure in assemble language. Solution: start with C, generate the assembly language source file, then toss the C code and hand edit the assembly. In the same way, I think you're going to have to muck with the generated code that Matisse (NetBeans) makes for you. You might try making a three panel form on your own, note what constraints Matisse uses, then create a method to swap between those two configurations. This is basically the same as adding (or removing) a component to a different layout manager, like FlowLayout or BoxLayout, except GroupLayout probably has more constraints that GridBagLayout and will be a pain to work with. On the bright side if you reuse the code Matisse generates you only have the one split pane to mess with. An SSCCE would help immensely. If you can, post the form file that Matisse generates as well.
From: Knute Johnson on 15 Sep 2009 18:19 Andreas Leitgeb wrote: > I've got difficulties with JSplitPane: > Some dialog consist of four parts (vertically), with sliders between each. > That was created by a colleague with netbean's form-editor, and works almost > ok. There is one master-JSplitPane, and two inner JSplitPanes and inside > that are the actual components. > > Now, "they" want a special behaviour: if the bottom-most component > is hidden (with slider's arrow-buttons on windows), then the other > three components should all grow to fill the available screen-estate, > and if the last one is made visible again, then all the other ones > should shrink equally a little to make room for the last one. Do they want the sliders between to move? > I'm a bit at loss. It seems to do a lot already on closing/reopening > that last part. Things that I can only assume is implemented in the > JSplitPane (as I didn't implement it myself; perhaps that goes auto- > magically based on Components' preferred- and minimum sizes), but it > doesn't propagate that extra space to the upper sibling in the master > JSplitPane. I.e.: only the upper component of the lower inner JSplitPane > gets all the extra space. > > How would I better arrange or tweak those SplitPanes such that size- > propagation among the other Components works more "natural"? > > I tried to become friends with netbeans, but netbeans obviously refused > my friends-request and misunderstood all my attempts at dragging > components around in the form-editor to the point that even repeated > "undo" didn't restore the old state, but only exiting and restarting > netbeans did. In the end, if I have to restructure the hierachy, I'll > probably have to hand-edit the .form file as well for it to remain > consistent with the .java, in case future colleagues will want to edit > that dialog after me and to whom netbeans is more cooperative. > (freshly installed netbeans 6.1.7 here) > -- Knute Johnson email s/nospam/knute2009/ -- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
From: Andreas Leitgeb on 16 Sep 2009 05:24 markspace <nospam(a)nowhere.com> wrote: > Andreas Leitgeb wrote: >> How would I better arrange or tweak those SplitPanes such that size- >> propagation among the other Components works more "natural"? > I think it depends on the type of LayoutManager your component uses. The inner LayoutManager works well (as seen when manually resizing it) and also sets sane Preferred- and MinimumSizes. For the sake of my problem I think we could just as well assume it were JButtons. >> I tried to become friends with netbeans, but netbeans obviously refused >> my friends-request and misunderstood all my attempts at dragging Meanwhile I understand some of netbeans misunderstandings... I was irritated by some component added in one but not the other parts, that had no use at all, and was later replaced, anyway. As it seems, the colleague who did that wasn't really friend with netbeans, either. > Old timers trick: > You have to write a complicated procedure in assemble language. > Solution: start with C, generate the assembly language source file, then > toss the C code and hand edit the assembly. I get the point :-) > This is basically the same as adding (or removing) a component to a > different layout manager, ... That last component isn't really to be removed/added dynamically, but only invisibilized by its slider sticking at the bottom of that particular JSplitPane, so the user can "restore" it using the slider.
From: Andreas Leitgeb on 16 Sep 2009 05:36
Knute Johnson <nospam(a)rabbitbrush.frazmtn.com> wrote: > Andreas Leitgeb wrote: >> Now, "they" want a special behaviour: if the bottom-most component >> is hidden (with slider's arrow-buttons on windows), then the other >> three components should all grow to fill the available screen-estate, >> and if the last one is made visible again, then all the other ones >> should shrink equally a little to make room for the last one. > Do they want the sliders between to move? Yes, of course the sliders all have to move for the components to change size as requested. E.g. if normally each of the 4 component has an extent of 300 pixels in the relevant direction, and then the last one is hidden, then the remaining ones should grow to 400 pixels to compensate for the space left behind by the last one, and if the user clicks on the slider- button to make that last one visible again, then all the components should settle at 300 pixels again, unless the user sets other sizes. Up to a few questions (which I'll ask in a new thread), I think I mostly understand the mechanics of a single JSplitPane. It's the cascading of multiple JSplitPanes that still troubles me. |