Update a ListBox from another ListBox click


I made two ListBox with several items each, I would like to update or make changes to the second list according to what I click on the first one.

So I can implement the listBoxItemClicked on the first, but how can I send the data to the second list?

What I'm trying to do is basically a sort of browser with Categories, Tags and other things, so clicking on a category would show only certain tags etc...

Thanks in advance.


You could make your ListBoxModel subclass Action or ChangeBroadcaster and then add the parent component (of both listsboxes) as a listener. The parent component could then trigger the update to the first list when the second list changes.


That worked. The problem was that I had the ListBoxModels nested.

Anyway, I think there's something wrong with the behavior of updateContent(), it updates the content only if the number of rows is different than the previous size. What if I decide to change the list but it's the exact same size of the previous one? It won't update until I change the size first.


Yeah, I've been puzzled by this several times in the past, and somehow manage to forget that I know what is going on!

It does update, it just doesn't automatically trigger a repaint (i.e. if you call repaint() afterwards you should be okay). I can't say I've ever found myself in a situation where I didn't want a repaint to happen after updateContent, but it's easily solved so I've not really had a good enough reason to complain/request :).

That said, it would be really nice to not forget and puzzle over it again in the future! ;) 


Oh I didn't tought about calling reapint(), it works now!

I have a really bad memory, whenever I find something like that I alway try to comment/document my code or if necessary I make a note in a document that has all the info I would need to compile my stuff :D (kinda like a tutorial to my self!)

Anyway, thanks for the help!