Results 1 to 1 of 1
  1. #1
    kreyszig is offline Member
    Join Date
    Oct 2010
    Rep Power

    Question Writing a Class to Implement ListSelectionModel Directly?


    I would like to implement my own ListSelectionModel without extending it from DefaultListSelectionModel, because I need some special list that behaves in a special way. How can I actually set the selection state of individual cells from setSelectionInterval , without using JList.setSelectionInterval (which itself calls ListSelectionModel.setSelectionInterval)? I can implement ListSelectionModel.isSelectedIndex correctly, but the problem I have is that it won't get called systematically...

    What I need my list to do more specifically is to be able to change the selection state of any cell in the list if ListSelectionMode.setSelectionInterval gets called with a given range of indices. The only solution I have found so far is to extends DefaultListSelectionModel and then call:


    in my overriden implementation of setSelectionInterval, after doing the necessary changes to my interval list such that my overriden implementation of isSelectedItnerval returns the right values. However, this solution is extremely inefficient and I want to avoid it if possible. As I said, I want to write my own class to implement ListSelectionModel instead of extending DefaultSelectionModel.

    Last edited by kreyszig; 01-24-2011 at 04:26 PM.

Similar Threads

  1. Calling a class method directly?
    By noobForever in forum New To Java
    Replies: 8
    Last Post: 12-04-2010, 03:58 PM
  2. Writing a class
    By smray7 in forum New To Java
    Replies: 3
    Last Post: 11-30-2010, 06:16 PM
  3. Replies: 1
    Last Post: 10-02-2009, 01:35 AM
  4. Can I call directly the *.class
    By doanhanam in forum New To Java
    Replies: 1
    Last Post: 11-16-2008, 07:24 PM
  5. Implement a class Employee-Help due tmrw!
    By Britt7 in forum New To Java
    Replies: 3
    Last Post: 10-27-2008, 01:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts