DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: JList returns

  1. #1
    Join Date
    Oct 2005
    Posts
    11

    JList returns

    Can anyone please enlighten me as to what a JList returns? If I have a list of 10 items and the user selects 3, do I need a listListener to capture that information and is there a way to limit selections to three instead of the MULTIPLE_INTERVAL_SELECTION?

    Thanks.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    That depends on the method you use.
    Code:
    // To get all selections use:
    
    Object [] ob=aList.getSelectedValues();
    
    // then typecast to what you know is in the list
    
    MyClass mC=(MyClass)ob[0];
    
    //to limit this to three use:
    
    if (ob.length > 3) {
      /* signal error: "can  select max  three" */
    }
    
    //to set selection limits
    
    aList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    PS: still that blank insert in the code tag
    its: SINGLE_INTERVAL_SELECTION
    eschew obfuscation

Similar Threads

  1. Horizontal Dispaly of Images in JList
    By datechie in forum Java
    Replies: 3
    Last Post: 06-13-2005, 10:34 AM
  2. Scrollable Jlist
    By matt in forum Java
    Replies: 1
    Last Post: 12-04-2001, 10:44 AM
  3. Replies: 1
    Last Post: 07-12-2001, 06:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links