How to implement a JSplitpane bean

Hi, I’ve been struggling to get it working, but in the end it wasn’t that difficult.

Basically, the issue is that the elements that you want to have in the two parts of the split pane need to be on the same form as the JSplitpane bean.

Since most likely you want to have a form in each part of the split pane and forms are not elements on other forms, you have to work around this. Luckely, Servoy offers the oppertunity to, sort of, place a form in a form, by using a tabpanel of which you set the TabOrientation to “Hide”.

Currently, TabPannels can only show related forms, but I think we’ll be seeing unrelated tabpannels shortly.

So, place two TabPannels on your form + the JSplitPane bean. Be sure to name all three elements (else you cannot call them in a method).

Now, create the following method whcih you attach to the form as an OnLoad event:

elements.split.orientation = 0 //0 = horizontal split, 1 = vertical split
elements.split.topComponent = elements.tabs1; //assign 1st tabpanel elements.split.bottomComponent = elements.tabs2; //assign 2nd tabpanel
elements.split.dividerLocation = 145; //set the position of the pane divider

(in my example, the bean is called “split” and the tabpannel are called “tab1” and “tab2”)

When you now open the Form in view mode, you will see both froms that were in the TabPanels inside the JSplitpane bean. To get rid of the original TabPanels (yes, they are also still on the main form, but not accessible), just place then under the JSplitpane bean.

Hope this helps you…

Paul

Great information, Paul :D
Where can I download this bean?

Thanks again…

That is the cool thing… you don’t have to!

It ships standard with Servoy. Click the Place Bean button, right next to the Place Portal button in Develloper and select JSplitpane.

One little issue: sometimes beans go missing when develloper is closed. This will be fixed in beta 6, according to Jan, which is scheduled this week, according to Johan… :D

Paul

Thanks Paul, this tip learns me to dig deeper like you did. Never thought of just calling the element without any method.

Don’t forget to anchor fields and forms. It works like a charm!

Great tip…

For some odd reason I can’t drag the splitter. Anyone else experiancing this? Also the positioning of the splitter doesn’t work. :cry:

I would love to be able to use the splitpane.

Well, it should work, maybe you can try to put the splitpane in the foreground… Positioning is remembered in the properties maybe you can set it to the position you want also!

Positioning of the Splitter thorugh a method has to happen after you assign the top/bottom or left/right components, or else it’s directly overwritten. Maybe that happens?

As for not being able to move the splitter: probably a property of the bean that you have to set? I never experienced this.

Paul

I use the exact source you gave.

I experimented with other controls in it like buttons (using the same names).
Same result. They all resize to the max size inside the splitpane and the splitter can’t be moved. I removed all anchors from the buttons tho…still they resized. Normal behavior ?

I am using Mac OSX 10.3.2 and Servoy 1.2-build 259
Also the beans are always missing after quitting and opening servoy.
Known bug I know.

Very odd, never seen it. I do know that I work with Servoy 2.0 beta’s. Maybe something has been fixed in new versions…

The problem that beans go missing after closing Develloper is at least fixed in 2.0 beta 6.

Paul

Hi ,

thanks for sharing the technique …

now, with the recent release (12), you have to change the method:

elements.split.setOrientation(1); //vertical
elements.split.setLeftComponent(elements.tabs1);
elements.split.setRightComponent(elements.tabs2); 
elements.split.setDividerLocation(0.2); //Location as value betwen 0 and 1