What I am trying to do with a JList
is be able to select an index by either scrolling with the mouse or using the keyboard up or down buttons without requiring a key press or mouse click event. I have tried looking into listeners and I think that's the right direction to go but if someone could put it simply I would appreciate it so much.
//edit.
To add more detail here is an example of what i mean, see Halo 3 is high lighted but the stock item name etc is for halo 4
You need to add a ListSelectionListener
to the ListModel
of the JList
. Then when the selection event is generated you invoke your logic to update the two text fields.
Read the section from the Swing tutorial on How to Write a List Selection Listener for more information and examples.
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.