I'm working on a custom JFrame that has a Box in a JScrollPane initialized as such:
box = new Box(BoxLayout.Y_AXIS);
jScrollPane1.getViewport().setView(box);
Originally, everything works fine, but later when I update the components inside the Box, the components are not clickable (listeners are not invoked, instead the entire Box flickers with each click). Here is the code to update the components:
box.setVisible(!entries.isEmpty());
box.removeAll();
entries.stream()
.map(entry -> new GUIPassEntry(passman, entry))
.forEach(box::add);
box.validate();
GUIPassEntry is a custom subclass of JPanel.
I learned that a validate() or revalidate() call is required so that the Box updates visually with the new components. However, after this code is run, the components inside the Box are no longer clickable.
Does anyone know what's going on here?