开发者

Find out if JList has an item currently selected

开发者 https://www.devze.com 2022-12-13 06:42 出处:网络
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 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
开发者_JAVA技巧

Maybe this isn't even possible... ?


Use:

    list.setSelectedIndex(0);
0

精彩评论

暂无评论...
验证码 换一张
取 消