I am building a Swing application in Java using NetBeans and I have a layout problem. My main frame contains JScrollPane
, which contains JPanel
, called contentPanel
, which, in turn, contains JPanel
, called listPanel
. When the program starts, it is listPanel
empty, but when the user interacts with the program, an unpredictable number of smaller ones are added to it JPanel
. I used the NetBeans Builder GUI to snap the top edge listPanel
to the top contentPanel
, as well as to the bottom edges.
The problem is that when adding more components to the listPanel
vertical scrollbar does not appear on my scrollpane. verticalScrollBarPolicy
my scrollpane is set to AS_NEEDED
, and its viewportView
set to contentPanel
. I think what I need to do to make it contentPanel
grow when listPanel
more elements are added.
source
share