File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Need help with JList selection modes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need help with JList selection modes" Watch "Need help with JList selection modes" New topic

Need help with JList selection modes

Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I have an application using a JList and I want to implement the additional restriction that as long as the list is non-empty there will always be one element selected. I am using the SINGLE_SELECTION model but that allows the user to deselect the current item and leave no elements selected. I suspect I can accomplish what I want using a ListSelectionListener but I haven't found enough documentation on that object for me to determine whether it would be helpful.

Is there anyone out there who can help me out with this?


Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
It is sorta covered in the JavaRanch Style Guide.
subject: Need help with JList selection modes
It's not a secret anymore!