I am currently writing a little program in Swing. And I hit a problem I can't seem to be able to solve alone.
In my program I have a list of objects of unkown size. They are displayed as panels organized in a GridLayout. Each panel take a line of the GridLayout.
I would like, if there are more than 10 objects to show only 10 and have a vertical scroll bar to see all objects.
I encounter 2 problems:
1) I can't seem to be able to show only 10 lines, everything is displayed.
2) I can't seem to have a working scroll bar.
I wrote this code as a simplification of my problem:
Here is the result:
I tried things like setting sizes or preferred sizes for almost everything. I tried to change the number of rows of the GridLayout but nothing helps. I am clearly missing something, I don't know what.