I am new to Java GUI Development and I am unable to understand scrollpane for dynamic label addition during runtime in JAVA SWING. I can't find very good documentation for the swing components as well. Can someone please explain me how Scrollpane works ? Some of my questions may sound very stupid but I have been struggling with them since yesterday :-
1.) What is scrollpane ?-->Very basic I know...! I guess if this gets answered, everything else would be resolved.
2.) Is scrollpane added to Frame ? Or, is Frame added To scrollpane ? Or, both of them are OK ? Can we add panel to scrollpane ? A textarea ?
3.) Can we make ANY swing component to be scrollable if we use scrollpane ? If yes, how ?
4.) If lets say some component (say frame) is connected to a scrollpane (not sure if "connect" even makes sense here) AND I wish to add new labels to this scrollable area, how should i do it ? Should I simply add the new label to the main enclosing frame ? or, should I add it to the scrollpane ?
5.) Why should we use the gridlayout (or similar) function always before adding something to scrollpane/frame and really, what does it do ?
Thanks for any guidance you can give !! If you feel that my questions are too basic, a pointer to some good documentation would not be such a bad idea as well.
Here is a list of links:
JScrollPane tutorial and documentation:
JFrame tutorial and documentation:
GridLayout tutorial and documentation:
All of the answers to your questions are there.