Reputation: 1774
I need to make a scroll box that can contain an unknown number of elements. Namely it needs to be able to scroll. I'm not quite sure how to do this. Please help.
Upvotes: 2
Views: 2418
Reputation: 2446
Use a JScrollPane with a JPanel wraped inside it. That way, you can add any number of elements to the JPanel without exceeding the panel's physical size using the JScrollPane.
Here is one part of the very famous oracle tutorial that explains the JScrollPane element: http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html
I hope this helps!
Upvotes: 6