aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How we can restrict the no of selections in a JList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How we can restrict the no of selections in a JList" Watch "How we can restrict the no of selections in a JList" New topic
Author

How we can restrict the no of selections in a JList

kota murali
Greenhorn

Joined: Jun 26, 2002
Posts: 1
Hi,
How we can restrict to select max. no of items in a JList.
Ex: JList has to restrict that user can select max of 3 selections which is having 50 items.
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
I don't think there is any direct way to do that but you can add a listener to the list
(addListSelectionListener) that's notified each time a change to the selection occurs.In case user selects more than three you can call
clearSelection() to change the selection to empty set.


Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

"k murali" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How we can restrict the no of selections in a JList