Code for limiting JSplitPane width does not work in Servoy 4

Hi

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();

leftMinDim.width = 220;
rightMinDim.width = 800;

elements.vSplit.leftComponent.setMinimumSize(leftMinDim);
elements.vSplit.rightComponent.setMinimumSize(rightMinDim);

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.

Hello Harjo

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.

The parameter for the JSplitPane requires a Dimension type object, not integer numbers.
I tried this code and it works ok:

elements.bean_6.setMinimumSize(new java.awt.Dimension(100,60))

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

Upon further testing it seems that the only change is the minimumSize() is now getMinimumSize().
I tried this and it works:

	var leftMinDim2 = elements.bean_6.leftComponent.getMinimumSize();
	var rightMinDim2 = elements.bean_6.rightComponent.getMinimumSize();
	leftMinDim2.width = 100;
	rightMinDim2.width = 60;
	elements.bean_6.leftComponent.setMinimumSize(leftMinDim2);
	elements.bean_6.rightComponent.setMinimumSize(rightMinDim2);

Hi Thomas

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:

elements.bean_6.setMinimumSize(new java.awt.Dimension(100,60))

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

Hi Thomas

I tried that idea but I still get the errors as seen in my attachements. I am wondering why this works in your environment, though!?

Thanks and best regards, Robert

Thomas Parry:
Upon further testing it seems that the only change is the minimumSize() is now getMinimumSize().
I tried this and it works:

	var leftMinDim2 = elements.bean_6.leftComponent.getMinimumSize();
var rightMinDim2 = elements.bean_6.rightComponent.getMinimumSize();
leftMinDim2.width = 100;
rightMinDim2.width = 60;
elements.bean_6.leftComponent.setMinimumSize(leftMinDim2);
elements.bean_6.rightComponent.setMinimumSize(rightMinDim2);

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

Hello Thomas

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

Hello all,

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();

leftMinDim.width = 220;
rightMinDim.width = 800;

elements.vSplit.leftComponent.setMinimumSize(leftMinDim);
elements.vSplit.rightComponent.setMinimumSize(rightMinDim);

So it strongly necessary to have the left, and right panels set, before using them.

Hope this helps,

Alex

Hello Alex

Sorry for the delay of my answer, but I am coming back to the problem now.

It seems I did not show all of my code, sorry. Here it is:

elements.vSplit.orientation = 1 // vertical split
	elements.vSplit.leftComponent = elements.tabSelection; // 1st tabpanel assignment	
	elements.vSplit.rightComponent = elements.tabDetail; // 2nd tabpanel assignment
	elements.vSplit.dividerSize = 2; // Size (thickness) of the pane divider 
	elements.vSplit.oneTouchExpandable = true; // Little widget provided to quickly expand/collapse the split pane  
	elements.vSplit.resizeWeight = 0; // Do not resize left and right component proportionally
	elements.vSplit.dividerLocation = 220; // Position of the pane divider
	elements.vSplit.continuousLayout = true; // Views are continuously redisplayed while resizing
	elements.vSplit.doubleBuffered = true;
	
	// Limit the minimum and maximum selection pane width
	var leftMinDim = elements.vSplit.leftComponent.minimumSize();
	var rightMinDim = elements.vSplit.rightComponent.minimumSize();	
	
	leftMinDim.width = 220;
	rightMinDim.width = 800;

	elements.vSplit.leftComponent.setMinimumSize(leftMinDim);
	elements.vSplit.rightComponent.setMinimumSize(rightMinDim);

So as far as I understand you, the 2 statements:

elements.vSplit.leftComponent = elements.tabSelection; // 1st tabpanel assignment
elements.vSplit.rightComponent = elements.tabDetail; // 2nd tabpanel assignment

should do what you call leftPanel and rightPanel, shouldn’t it?
The problem is I still get the error!?

elements.vSplit.leftComponent and elements.vSplit.rightComponent are not null as you mention but have this values:

elements.vSplit.leftComponent = SpecialTabPanel, name=‘tabSelection’, hash 9768343
elements.vSplit.rightComponent = SpecialTabPanel, name=‘tabDetail’, hash 9062642

This is an expected result, is it? Any idea?

Thanks and regards, Robert

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.

Hope it helps

Hi jbader

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?

Thanks and best regards, Robert

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?

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?

  1. It must be possible to make the width bigger but also only to a defined maximum width.
  2. 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?

Hello Harjo

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.

nope, does not work here also.

Hi Harjo

Thanks for your info, sometimes one thinks to get crazy :evil:
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.

Regards, Robert

Harjo:
nope, does not work here also.