# JSplitPane - resizing & using

**URL:** <https://forum.servoy.com/t/jsplitpane-resizing-using/4370>\
**Category:** Classic Servoy\
**Created:** [June 16, 2005, 6:19pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370 "2005-06-16T18:19:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjekl](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@mjekl](https://forum.servoy.com/u/mjekl)\
**Post date:** [June 16, 2005, 6:19pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/1 "2005-06-16T18:19:07Z")

</div>

I’ve been trying to make JSplitPane work.

Some Great resources are:  
[http://forum.servoy.com/viewtopic.php?t … jsplitpane](http://forum.servoy.com/viewtopic.php?t=1057&highlight=jsplitpane)  
[http://www.servoymagazine.com/home/2005 … ing\_b.html](http://www.servoymagazine.com/home/2005/03/article_using_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

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [June 16, 2005, 7:20pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/2 "2005-06-16T19:20:10Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![mjekl](https://avatars.discourse-cdn.com/v4/letter/m/5fc32e/32.png) [@mjekl](https://forum.servoy.com/u/mjekl)\
**Post date:** [June 17, 2005, 2:33pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/3 "2005-06-17T14:33:09Z")

</div>

> 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]( "Very Happy") ![:D]( "Very Happy")

mjekl

---

<div class="post-metadata">

**Author:** ![Odysseus](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@Odysseus](https://forum.servoy.com/u/Odysseus)\
**Post date:** [June 26, 2006, 9:45pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/4 "2006-06-26T21:45:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [June 27, 2006, 6:57am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/5 "2006-06-27T06:57:54Z")

</div>

Check out these examples. They should help you

[http://javaalmanac.com/egs/javax.swing/split\_SplitPane.html](http://javaalmanac.com/egs/javax.swing/split_SplitPane.html)

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 27, 2006, 6:58am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/6 "2006-06-27T06:58:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Odysseus](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@Odysseus](https://forum.servoy.com/u/Odysseus)\
**Post date:** [June 27, 2006, 8:39am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/7 "2006-06-27T08:39:35Z")

</div>

Paul  
regarding 1)

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

```auto
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

```auto
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

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 27, 2006, 8:53am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/8 "2006-06-27T08:53:24Z")

</div>

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]( "Very Happy") ) 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

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 27, 2006, 8:57am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/9 "2006-06-27T08:57:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Odysseus](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@Odysseus](https://forum.servoy.com/u/Odysseus)\
**Post date:** [June 27, 2006, 9:24am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/10 "2006-06-27T09:24:27Z")

</div>

PROBLEM SOLVED

```auto
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

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 27, 2006, 9:28am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/11 "2006-06-27T09:28:11Z")

</div>

Nice ![:D]( "Very Happy")

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

Paul

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 27, 2006, 10:16am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/12 "2006-06-27T10:16:13Z")

</div>

thanks! ![:D]( "Very Happy")  
great tip!

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [June 27, 2006, 10:16am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/13 "2006-06-27T10:16:29Z")

</div>

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]( "Very Happy")
> 
> Do check if this solution works in 3.0 (te settign of the forms as components directly, without using tabs).
> 
> Paul

 ![loadSplitPaneError.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/3/3a42dc027e405f341c5b77438c0f126f414e62c8.png)

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [June 27, 2006, 10:39am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/14 "2006-06-27T10:39:29Z")

</div>

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
> 
> ```auto
> 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)

> ```auto
> 
> 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
> ```

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 27, 2006, 10:52am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/15 "2006-06-27T10:52:46Z")

</div>

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]( "Very Happy")

Paul

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [June 27, 2006, 12:01pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/16 "2006-06-27T12:01:33Z")

</div>

Thanks, Paul, for the explanations, very helpful!

Best regards, Robert

---

<div class="post-metadata">

**Author:** ![Odysseus](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@Odysseus](https://forum.servoy.com/u/Odysseus)\
**Post date:** [June 27, 2006, 7:56pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/17 "2006-06-27T19:56:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 28, 2006, 6:55am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/18 "2006-06-28T06:55:06Z")

</div>

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

Paul

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [June 28, 2006, 11:14am UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/19 "2006-06-28T11:14:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Odysseus](https://avatars.discourse-cdn.com/v4/letter/o/cdc98d/32.png) [@Odysseus](https://forum.servoy.com/u/Odysseus)\
**Post date:** [June 28, 2006, 1:15pm UTC](https://forum.servoy.com/t/jsplitpane-resizing-using/4370/20 "2006-06-28T13:15:19Z")

</div>

Well…

first of all glad I got you started to think ![:lol:]( "Laughing")

> 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

[Next page](https://forum.servoy.com/t/jsplitpane-resizing-using/4370.md?page=2)
