JList

Hi friends

I have a requirement in which the best and simple way to fulfill the functionality ....is to have some way to set a particular element(row) in JList visible false.

This solution will help me to remove coding for adding ,removing and sorting elements of JList .

I went through custom ListCellRenderer example..which have an interface which wont solve the problem.

Does any one know the solution for this and also is it possible to do using ListCellRenderer ?

Thanks

-Sunny Jain-

[532 byte] By [sunnyjaina] at [2007-11-27 8:16:06]
# 1

Why would hiding a row be simpler than removing it from the model?

Anyway ListCellRenderer is the wrong approach.

If you really want something like this I would suggest wrapping the ListModel inside another model (something like TableSorter) that has visible attribute for each row.

And will return the corrent element for each index depending on the visibility of rows in the model.

Rodney_McKaya at 2007-7-12 20:00:57 > top of Java-index,Desktop,Core GUI APIs...
# 2
Reason for making visible false is only those elements that are visible true will be displayed and when i add the elements back i can make them visible true.Another Reason i want to use JList is that i allows filtering .as i am new to swing ,i am unable to understand
sunnyjaina at 2007-7-12 20:00:57 > top of Java-index,Desktop,Core GUI APIs...
# 3
I think the easiest way would be to store your objects in a separate array or LinkedList for example and just use the remove methods of the ListModel.That way it saves you having to implement extra functionality to hide rows etc.
c0demonk3ya at 2007-7-12 20:00:57 > top of Java-index,Desktop,Core GUI APIs...