简体   繁体   中英

Find out if JList has an item currently selected

I have a JList which is populated after importing a file. Is it possible to have the first item/element of the JList highlighted/selected. I have browsed many places hoping to find a line along the lines of

list.setFocus(0);
//or
listSelectionEvent.setSelection(0);
//0 referring to index point of the list

Maybe this isn't even possible... ?

采用:

    list.setSelectedIndex(0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM