expandable JPanel while adding items
I have a JFrame and I added JPanel inside it
However, I designed in a way, I can add JButton to that panel
it is used as a bookshelf
for example
btn 1 btn2 btn3
so each time i add, it goes three columns and then shift down to a new row
this worked perfect, I added JScrollPane to that panel
I want this to go unlimited number of rows,
so, until now, whe I add 8 rows it works find, the Jscroll shows all the jbutton
but when I add more buttons it goes under the frame/or panel
and JScroll does not show it.

I tried to play with (setperefredsize)
but no solution. How can I accomplish this?

Also, is this a good practice? I mean having unlimited Height size for panel?
that is, adding new jbutton will cause to extend the panel withing the JScroll, with no fix number.
is this good practice?

I see no problem with adding unlimited button to a panel and let it extend down the display while you can still scroll down. However, too many buttons may cause you problem, so you may need to redesign the layout of what you are doing.

So could you please show the code part that you do the adding to the panel and may be repaint?

Thank you,
I see,
if you don't mind, what kind of problems?
What I'm doing is, each button represent A book-cover
Sorry, the code is kinda complicated that why I don't see need to post it.
I just wanted a genral idea as you see. :)

This question has already been answered. Start a new discussion instead.