开发者

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
开发者_JAVA技巧

Maybe this isn't even possible... ?


Use:

    list.setSelectedIndex(0);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜