Basically, you should not use JScrollPane#add .
JScrollPane has one component already connected to it, JViewport , this is what JScrollPane uses to display any component added to the view port.

setViewportView - convenience method for JScrollPane#getViewport#setView
The basic concept is that in terms of scrolling, only one component is displayed, so add doesn't really make any sense for this. This method is the result of an extension from JComponent Container
MadProgrammer Nov 22 '13 at 6:09 2013-11-22 06:09
source share