JScrollBar bean usage

Hi all,

I’m working with Servoy 3.5.10. I need to create a simple scrollbar related to the foundset of the current form defined as view 'Record form (locked). AFAIK defining Scrollbars on this type of form does nothing so I need another way of doing this.
I found the JScrollBar bean available in the standard Servoy distribution, dropped it on my example form and named it ‘myScrollbar’.
I’ve initialized main properties of the bean in the method connected to the onShow event with the following code:
controller.find();
controller.search();
elements.myScrollbar.minimum = 1;
elements.myScrollbar.maximum = controller.getMaxRecordIndex();
elements.myScrollbar.setBlockIncrement(1);
elements.myScrollbar.setUnitIncrement(1);
// Some code is missing here part 1 see later…
return;
then I want to eventually delete the object/listener/whatever.needed it in the method connected to the onHide event with the following code
// Some code is missing here part 2 see later…
return;
I know I need to define a listener to move to next or previous record depending on the user action. This listener should call a third method, let’s call it positioningOccurrence, I actually defined as:
if (elements.myScrollbar.valueIsAdjusting)
{
if (elements.myScrollbar.value < elements.myScrollbar.minimum || elements.myScrollbar.value > elements.myScrollbar.maximum)
{
elements.myScrollbar.value = controller.getSelectedIndex();
}
else
{
controller.setSelectedIndex(elements.myScrollbar.value);
}
}
return;
Now my problem is JScrollBar AFAIK is not a pure swing object because I have not found it in the java documentation;
it should be in my opinion a Servoy not fully adapted object (is this true?)
I was expecting to defined something like these two missing parts of codelines:

// Some code is missing here part 1
var chgListener = new Packages.javax.swing.event.ChangeListener({ valueChanged: positioningOccurrence});
elements.myScrollbar.addAdjustmentListener(chgListener);

// Some code is missing here part 2
var chgListener = elements.myScrollbar.getAdjustmentListeners();
elements.myScrollbar.removeAdjustmentListener(chgListener);

Those lines are obviously wrong because they are not working at all !!!
I spent already time and efforts googling and digging documentation :roll: but I didn’t find a solution… :(

Can some Java expert give me some hints?

Tnks,
Gianni

gianni:
Now my problem is JScrollBar AFAIK is not a pure swing object because I have not found it in the java documentation;

Yes it is: javax.swing.JScrollBar

gianni:
it should be in my opinion a Servoy not fully adapted object (is this true?)

None of the swing objects javax.swing.* are “fully adapted” - they are not aware of Servoy, it takes some work to make them aware. See my tutorials on the subjet of Servoy Aware Beans.

The thing is that in Swing you never really use a JScrollBar as such, you usually have it for free using a JScrollPane, where you lay out your components. Although it is not impossible to use it directly, you are going to run into big problems with events in any case. It’s just not meant to be use directly in Servoy.

If all you need is a component to replace the standard “navigator”, you can have a look at the Slider Bean which has been explained at length in my Bean tutorial http://www.servoy-stuff.net/tutorials.php

Hope this helps,

Hi,

I have a question: I want to “connect” a Form to an JSScrollbar.
What I have to do? I don’t want connect it to the foundset but the possibility to scrooll of a form(created by enviroment or solutionModel).
I can’t use the standard scroll.
I explain me better,my situation is the follow:
[attachment=0]example.JPG[/attachment]
1 - is a tab with a table-view form
2 - is a detail Form that contain more tabpanel
3 - is the main form

My most important needs is that when I scroll up/down, both tab “1” and tab “2” have to scrool up/down ,instead when I scroll right/left only the tab"2" have to scroll.

Hi Marco,

don’t know if you found a solution yet, but maybe this approach can help you:

I understand your needs for one(or more) columns being a fixed part of your table and you being able to scroll down simultaneously both the fixed and flexible columns of the table.

I’ve seen something like you want, but here were pages involved.
So depending on the visibility of ‘more’ columns you had to click to the next page.
You could follow the same approach but using the slider bean if you want so.

Imagine a tableview having a few columns A B C D E F G H I J, where column A is your fixed column.
Besides you’d have room for - let’s say - 3 columns.

This means your starting point would be showing col A + BCD. You can easily set the ‘visible’ property of the other columns to false.
Your can setup your slider to take 7 values. Depending on the value of the slider you simply set visibility of elements true/false
Now you can easily show col A, but with 7 different ‘flexible’ column combinations: BCD, CDE, DEF, EFG, FGH, GHI, HIJ.

It’s not much work to request the number of elements on a tableview, which can make this thing work for a whole solution using only 1 global method.

Hope this helps

Ty mboegem but I have a complex situation because(for example)the point number 2 into the picture is a detail form built by solution Model that contain more tab panel created on the fly so I need to scroll the Form with JScrollPane or JScrollBar,but this is only an Idea.

thanks again for your answer

Marco