Would you mind helping me with this? In method updateTopicsSubjectsPanel( ) at line 375 I'm trying to remove all JCheckBoxes and then add a new list of JCheckBoxes.
I'm having trouble finding the right methods to call afterwards to have the JScrollPane display the new check boxes.
I've tracked pack( ) validate( ) revalidate( ) repaint( ) etc. but i can't get it to work. The JScrollPane remains blank.
Note: a JComboBox "topicGroups" listener' public void actionPerformed(ActionEvent e) calls updateTopicsSubjectsPanel( ) to populate the check boxes in JScrollPane "subjects_scroll" based on the value chosen in "topicGroups"
We don't care about your application, only the stated problem.
So you:
1) create a frame with a panel containing a couple of checkboxes
2) then you create a button and add it to the frame.
3. Then you add an ActionListener to the button that will clear the panel and add the new check boxes to the panel
The total length of the program will be about 20 lines of code. So it will be easy to debug and get working. If you have problems then you has a small piece of code to post. We don't have the time to look at 400 lines of code to see what you might be doing wrong.
Once you understand how it works, you apply the knowledge to your real class.
Also, you may want to consider using a CardLayout. This is the normal way of swapping panels in a frame. Read the Swing tutorial o How to Use CardLayout for working examples.
When the user chooses a value from the drop down "Groups of Topics" the list of check boxes on display in Topics.Subjects pane in the upper left is supposed to populate.
It does not appear to be possible to add JCheckBoxes to a JScrollPane, so I think that was indeed the problem.
I assumed it was possible, and that was my error.
I have added a test JCheckBox to the upper left pane - as you suggested - and seen that list dynamically change as it was supposed to after I replaced JScrollPane with JPanel.
Thank you very much for solving my problem.
Thank you very much for your time.
There was no need to change the method in question. frame.pack( ) is sufficient. I would post the corrected test code but I'm out of pie for now.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.