LOD121
LOD121

Reputation: 541

How do you make the items in a JList toggle when you click them?

I currently have a JList and I need the items to be able to be toggled with a single click, similarly to how Ctrl-click works when it is set to MULTIPLE_INTERVAL for the selection mode.

Is it possible to make the items select and deselect as follows if there are items A, B and C without making the user require Ctrl-click?

-The user clicks A, A is selected

-The user clicks B, A and B are selected

-The user clicks A, B is selected

Upvotes: 1

Views: 1602

Answers (1)

jzd
jzd

Reputation: 23629

The easiest way I can think to do this is to add a MouseListener and capture the clicks and manually select/unselect items.

Upvotes: 1

Related Questions