Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do you get a JList with Horizontal Wrap to move focus to the next line?

843806Sep 7 2007 — edited Sep 8 2007
I've got a JList that displays rows of thumbnails using
JList.setLayoutOrientation(JList.JList.HORIZONTAL_WRAP).
By default, the arrow keys let you navigate between the icons, but when it reaches the edge it stops. I would like the right arrow key to work like a typewriter and move to the selected/focus to the first element in the next row.

I tried to add a Keylistener to the JList that manually called
JList.setSelectedIndex( JList.getSelectedIndex() +1 )
but I found that it was skipping to the next line, but now moving *2* elements over.

Is this the right approach, but I need to find a way to cancel the native JList keyListener/Binding, or is there a way to manipulate the focus of the elements in a JList to allow wrap to the next line?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2007
Added on Sep 7 2007
3 comments
152 views