I'm having a requirement to develop a GUI based JFrame which should have capabilities to add Multiple JPanel on an event occurrence[Ex. button click] and the JFrame should be scrollable.

I tried a lot, but I failed. I also tried to add multiple Jpanel in JScrollpane that also failed. Can somebody help me please?

Thanks in advance,


Gokul Rangarajan

Add a single JPanel to the JScrollPane. Use FlowLayout with vertical (or horizontal, depending on which way you want to "scroll") alignment in that JPanel, and add the JPanels that are to be added "dynamically" to that JPanel. Then, don't forget to call validate() and/or repaint() on the JScrollPane.

Thank you masijade its working. Superb.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.