In porting to Servoy 4, this code doesn’t work any more and gives an error, saying function minimumSize() doesn’t exist. Anyone has code for limiting the JSplitPane width to share for Servoy 4?
Thanks and regards, Robert
Code:
// Limit the minimum and maximum JSplitPane width
var leftMinDim = elements.vSplit.leftComponent.minimumSize();
var rightMinDim = elements.vSplit.rightComponent.minimumSize();
I had the same issue, and I asked Johan about it, and he said, it was rather strange that SHOULD work in 3.5.
So fo now I had to remove the code, to get things working.
Don’t know the status right now, but you can always fill in a issue request.
Thanks foryour reply, I made an entry into the Servoy Support System. I also have to comment this code out to get it run.
Best regards, Robert
Harjo:
Hi Robert,
I had the same issue, and I asked Johan about it, and he said, it was rather strange that SHOULD work in 3.5.
So fo now I had to remove the code, to get things working.
Don’t know the status right now, but you can always fill in a issue request.
where you replace of course the 100,60 with your own width and height integer numbers.
If I do this:
elements.bean_6.setMinimumSize(100,60)
then it does indeed complain about cannot find method for this type of argument.
Another approach is to do is this:
var size = elements.bean_6.getMinimumSize();//returns Dimension type that has height and width as attributes
size.height = 100;
size.width = 60;
elements.bean_6.setMinimumSize(size);
Try my idea and let me know if it works in your case since mine is only a simple test.
Tom Parry
Thanks for your ideas and testing! Without the leftComponent or rightComponent part it works, but does not give the desired result, as I have to be able to access the left and right component of the bean. At least I did not find another way of limiting the left or right part of the bean.
Regards, Robert
Thomas Parry:
The parameter for the JSplitPane requires a Dimension type object, not integer numbers.
I tried this code and it works ok:
As you assumed, we use Mac OS X 10.4.11 and Java 1.5. So may be Servoyans know what’s wrong?
Regards, Robert
Thomas Parry:
Hi Robert,
I used Servoy 4.0.1 with Java 1.6 (build 1.6.0_07-b06) on winXP pro Sp3. I did not test on a MAC which I assume is your OS?
Tom
So regarding the JSplitPane, is a default JavaBean and it acts as a container.
Therefore, before calling - rightComponent, leftComponent- you have to place something in there.
If you dont do that, then the both components will return null. From there comes the exception mentioned above.
So regarding your example:
elements.vSplit.rightComponent = rightPanel ; (where rightPanel is an object that exists; lets say, of JPanel type)
elements.vSplit.leftComponent = leftPanel;
And after that…
var leftMinDim = elements.vSplit.leftComponent.minimumSize();
var rightMinDim = elements.vSplit.rightComponent.minimumSize();
If I understand correctly, I think you want to use JSplitPane’s setDividerLocation method, not [set]minimumSize.
setDividerLocation has two API’s: One that takes a number/double parameter and another that takes an integer parameter. The API that takes a number/double parameter sets the divider location as a percentage of the available space, so the allowed values are between 0 and 1 (e.g. .25 will set the divider location at 25% of the available space). More often than not though you will want to use the API with the integer parameter, which allows you to specify the exact width/height of the left/top or right/bottom component, but the question then becomes how do you pass an integer value into the API since JavaScript has no integer data type? For that there is a special syntax called “Explicit Method Specification (http://www.mozilla.org/js/liveconnect/l … icitMethod)”
elements.mySplitPane["setDividerLocation(int)"](n); // Where n is any number to be cast to an integer value
In the above example Rhino will cast n to a real Java Integer type before calling the setDividerLocation method thus allowing you to call the API with the integer data type as the parameter. I know this works in 4 'cause I use it often.
I use (in V3.5.7) and need to continue to use (in V4.x) the minimumSize, i. e. setMinimumSize method, as I want to limit the mimimum width of a JSplitPane in our app. The problem remains that I get errors when using the code in V4.0.1, although there is no problem running the same code (as shown in my previous post) in V3.5.7.
So I am still stuck. Do you also use the setMinimumSize method? Could you post your code running in V4?
Are you using setMinimumSize to set the width or height of the individual split pane parts e.g. To make the top 500px and the bottom 275px or are you using it to ensure an individual part is never smaller than the value you specify?
I use both but the example is to ensure that an individual part is never smaller than the value I specify.
jbader:
Are you using setMinimumSize to set the width or height of the individual split pane parts e.g. To make the top 500px and the bottom 275px or are you using it to ensure an individual part is never smaller than the value you specify?
It must be possible to make the width bigger but also only to a defined maximum width.
I think I would like to have it keep the width as set by the user. Of course it would be nice if it would grow or shrink proportionally to making the whole app frame bigger or smaller!
jbader:
OK, two more questions…
1). Do you care if it gets bigger than your minimum size?
2). Do you want it to default to the minimum size when the frame is maximized or packed?
Does the discussed code now work in your solution? It still does not work in Servoy 4.0.1 here, I tried all suggestions, but no luck. I always get the error: “TypeError: Cannot find function getMinimumSize …” (or minimumSize, if used as such).
I am really wondering if anybody has made the JSplitPane working with this and what the code looks like?
Thanks and regards, Robert
PS: BTW, no problems running the various variants in Servoy 3.5.7
Harjo:
Hi Robert,
I had the same issue, and I asked Johan about it, and he said, it was rather strange that SHOULD work in 3.5.
So fo now I had to remove the code, to get things working.
Don’t know the status right now, but you can always fill in a issue request.
Thanks for your info, sometimes one thinks to get crazy
We can’t make (the production) switch to version 4 (nor the development switch, as they have to go in parallel). I really hope it’s solved in 4.1.