JSplitPane - resizing & using

I’ve been trying to make JSplitPane work.

Some Great resources are:
http://forum.servoy.com/viewtopic.php?t … jsplitpane
http://www.servoymagazine.com/home/2005 … ing_b.html

In the mean while also found that all tab panes must be placed behind the JSpitPane bean on the Servoy form. This seems to be the cause for malfunction of the divider.

But still I’m looking to use JSplitPane in my main form, so I would like to resize it. Is this possible? Any hints?

Best,
mjekl

mjekl:
But still I’m looking to use JSplitPane in my main form, so I would like to resize it. Is this possible? Any hints?

If you are talking about setting anchors so it auto-resizes when you change the size of your window then you can do that by richt-clicking on the splitpane.
All beans can be anchored this way.

HTH

ROCLASI:
If you are talking about setting anchors so it auto-resizes when you change the size of your window then you can do that by richt-clicking on the splitpane.

HTH

:D :D

mjekl

I’ve been (bean?) playing with the splitpane bean. Some questions remain.

  1. on the forum I’ve reading that one needs to place tabpanels in order to display forms. In my experiments I’ve been setting the components directly from code (without using the tabpanels). This seems to work OK, so why do people use tabpanels ? Rephrased, What am I missing ?

  2. Something I’ve not been able to resolve is to fix the divider to a certain width (prohibiting the drag). It looks like one needs to set the minimumSize in order to accomplish this. However the SetMinimumSize seems to expect a Dimension, not an integer. I’m a bit a lost on how to provide this dimension to the function. Maybe you cannot “freeze” the divider in Servoy ?

Any insights are very welcome

TIA

Check out these examples. They should help you

http://javaalmanac.com/egs/javax.swing/split_SplitPane.html

Hi,

Regarding 1: What does your code look like? Which Servoy version are you testing this with?

Regarding 2: Haven’t been able to do so either, but according to the JSPlitPane docs, you need to set the minimumSize for the two components that you add to the two JSplitPane area’s. If the sum of the two minimumSizes of the two Components is bigger than the Size of the JSplitPane component, dragging of the divider should be disabled.

Paul

Paul
regarding 1)

Servoy Developer
Version R2 2.2.5-build 337
Java version 1.5.0_06-64 (Mac OS X)

elements.mySplitBean.rightComponent = forms['main_screen']
elements.mySplitBean.leftComponent = forms['controller_left']

if the sum of the two minimumSizes of the two Components is bigger than the Size of the JSplitPane component, dragging of the divider should be disabled.

Yep, that’s what I mean. The only problem seems to be that you need to feed the setMinimumSize a number of type Dimension, not of type Integer.
I tried using component.setSize (int,int) but that does not seem to work. So in order to do this I would need to do something along these java calls

myDim =  new Dimension
myDim.width = 150
component.setMinimumSize = myDim

I know there is a way of explicitly calling java from within Servoy, but can’t find it

THX

@Marcel:

Thanks for the link, looking into it

Mmm, if that works now (I mean the direct setting of a form as a component for the JSPlitPane), I guess the need for the TabPanels is gone. In the past, that didn’t work…

As for the minimumSize thing: You need to set the minimumSize for the Components you add to the JSplitPane, so to the two forms you add.

Servoy doesn’t offer this functionality for forms, I think. All formparts except the bodypart always have a fixed height. The bodypart has a dynamic height, depending on the size of the window.

Maybe you can get this done by using the TabPanels again ( :D ) and, though a plugin method set the minimumSize for the java component that represents the tabpanel. Note that this will only work in the rich client, since there you can grab the Java component. In the WebClient, this will not work.

Paul

BTW: the way to call Java code directly in Servoy:

var x = new Packages.xxxxx.yyyyy.zzzzz…

And secondly, I’m not sure that the direct setting of forms are component on the JSPlitPane is future proof. I know that in Servoy 3.0 the underlying structure of Servoy has changed and because of that, the code "forms[‘xxxxx’]’ doens’t point to a Java component directly anymore. So, I think setting forms directly as components on a JSplitPane will fail in 3.0, but I might be wrong (haven’t tested it).

Paul

PROBLEM SOLVED

elements.mySplitBean.rightComponent = forms['main_screen']
elements.mySplitBean.leftComponent = forms['controller_left']

var leftMinDim = elements.mySplitBean.leftComponent.minimumSize()
var rightMinDim = elements.mySplitBean.rightComponent.minimumSize()
leftMinDim.width = 150
rightMinDim.width = 1500
elements.mySplitBean.dividerLocation = 150
elements.mySplitBean.leftComponent.setMinimumSize(leftMinDim)
elements.mySplitBean.rightComponent.setMinimumSize(rightMinDim)

code is not optimised but you get the idea. Solution was to retreive a dimension through the minimumSize function. Then you get what in my book is called an property array , so you can adress the properties inside the array.

HTH

Nice :D

Do check if this solution works in 3.0 (te settign of the forms as components directly, without using tabs).

Paul

thanks! :D
great tip!

Hi All

I tried it and it doesn’t work in my app. I removed the tabless tab panels (including the tabpanel form reference). It works with tabless tabpanels.

Servoy Developer
Version 3.0b3-build 364
Java version 1.5.0_06-64 (Mac OS X)

Best regards, Robert

PS: How to read the lastDividerLocation?

pbakker:
Nice :D

Do check if this solution works in 3.0 (te settign of the forms as components directly, without using tabs).

Paul

Hi All

I get for var leftMinDim = elements.vSplit.leftComponent.minimumSize() this result: java.awt.Dimension[width=20,height=23]. For rightMinDim I get: java.awt.Dimension[width=19,height=24]

If I look on the JSPlitPane properties, I only have one min size property which is minimumSize = 93,29 (values on my case, don’t know where they come from). Where does the above values come from and what can be done with the minimumSize property? There must be some realtions between these properties and we seem to have a limited set in the Servoy property list?

Best regards, Robert

Odysseus:
PROBLEM SOLVED

elements.mySplitBean.rightComponent = forms['main_screen']

elements.mySplitBean.leftComponent = forms[‘controller_left’]

var leftMinDim = elements.mySplitBean.leftComponent.minimumSize()
var rightMinDim = elements.mySplitBean.rightComponent.minimumSize()
leftMinDim.width = 150
rightMinDim.width = 1500
elements.mySplitBean.dividerLocation = 150
elements.mySplitBean.leftComponent.setMinimumSize(leftMinDim)
elements.mySplitBean.rightComponent.setMinimumSize(rightMinDim)





code is not optimised but you get the idea. Solution was to retreive a dimension through the minimumSize function. Then you get what in my book is called an property array , so you can adress the properties inside the array.

HTH

The minimumSize property of the JSplitPane bean are what they are: The minimumsize for the JSplitPanebean. If you would anchor the bean on all 4 sides, the bean will never shrink to less than the minimum size. If you make the window smaller than the minimum size, the window will start to display scrollbars on the side.

How the values are generated, I’m not sure. Likely by the size you make the elements in designmode.

So, basically, the minimumSize (and equally, the maximumSize property) are there to determine the min and max size of a component when the component is set to shrink/grow when the underlying component shrinks/grows. In Servoy terms: This will be either a form, TabPanel or JSplitPane.

Setting a component to shrink/grow is done by setting anchors in Servoy.

Minimum and Maximum size are not implemented on elements by Servoy. Reason? Not sure… Maybe it’s due to the Choices Servoy made for layouts in Java. Java supports a wide range of layouts, but to Servoyians, this is all hidden from view, leaving the option to anchor elements on 4 sides, relative to the 4 sides of the form the element is on.

This choice makes crating a layout very simple: just place an element, size it and, if you want, anchor it. But on the other side, many of the features Java Layouts offer cannot be used when creating a form. For example: anchoring two elements together or spreading a number of elements over the full width or heigth of a form.

Maybe digging into the other layout options of Java components (like the discussed minimum and maximum properties will cause undesired effects in the form layout. Remedy: test well :D

Paul

Thanks, Paul, for the explanations, very helpful!

Best regards, Robert

Hi,

currently I have no acces to a 3.0 beta, so if anyone cares to test the above code for compability with 3.0 I sure would like to hear the feedback.

THX

I guess that is what Robert Huber did… Didn’t you, Robert?

Paul

BTW: I was thinking: If you do not want the user to be able to move the divider, why do you use the JSplitPane?

According to me, the only advantage of the JSplitPane is the ability for the user to move the divider, allowing him to view more or less of eihter form in the JSplitPane.

If you do not want him to do so, I think you’re better off just placing two Tab(less)Panels on your form.

Or am I missing something?

Paul

Well…

first of all glad I got you started to think :lol:

According to me, the only advantage of the JSplitPane is the ability for the user to move the divider, allowing him to view more or less of eihter form in the JSplitPane.

I would like to rephrase this and formulate my answers this way.

  1. The advantage of the JSplitPane is the ability for the programmer to give to the user the ability to move the divider when the programmer sees this fit. In other words, yes the user must have the ability to move the divider, but only when I (the programmer) wants him to have this ability.

  2. I’m chasing the solution for the problem where in certain conditions the labels labelling a listing layout scroll out of view, I haven’t been able to resolve this with tabpanels ( well sort of but with way to much work), and I feel I will be able to resolve this using “blocked” dividers

hth