Java Swing Listeners: components that listen to each other

I want to write two JList (categories and elements). When I click on one category, it should select all the elements for this category, and when I click on one element, it should select its categories. So the JList will be a ListSelectionListener listening on each other and changing the selection.

Should I be wary of some kind of "cycle "Is there a way to say that the event was destroyed? How do people deal with this situation?

thank

+3
source share
4 answers

, listA, ListSelectionEvent, listA, listB, , , listB , listB. , , listA. .

:

1 - . , getSource ListSelectionEvent. listB, list listA, listA, readd.

list1.removeListSelectionListener(this);
list1.setSelectedIndex(e.getFirstIndex()); //this would have to be played with to allow for intervals
list1.addListSelectionListener(this);`

2 - , , , , , . , .

+1

Beans API . NetBeans.

0

- , , . , ONCE, .

0

, . A A, , A .

-1

Source: https://habr.com/ru/post/1742589/


All Articles