How to deselect Jlist item on some event in java
Asked Answered
B

1

17

could any one suggest me any method or any other way in java that i could deselect my jlist item when some event occurs? i tried this but this does not seem to work

myJList.setSelectedIndex(-1);
myJList.ensureIndexIsVisible(-1);
Belak answered 7/3, 2012 at 5:14 Comment(1)
trying random api rarely is a good solution strategy (why would you thing that ensureIndexIsVisible has anything to do with selection?) - instead read the api doc and/or a good basic tutorial, f.i. the online swing tutorial linked to in the swing tag descriptionInterloper
S
41

Try myJList.clearSelection(); It clears the selection(s) on your JList object. If multiple list items selected together, they can also be deselected via this method.

Sexism answered 7/3, 2012 at 5:19 Comment(2)
Hello Deporter please read my This Question about loading a .Tif Image and please suggest me how to do it? i had put my code also which i tried [#9634972Belak
@AshishDonvir ok i will take a look at it now.Sexism

© 2022 - 2024 — McMap. All rights reserved.