jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes ListDataEvent ...looks Stange...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ListDataEvent ...looks Stange...?" Watch "ListDataEvent ...looks Stange...?" New topic

ListDataEvent ...looks Stange...?

Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
I have DefaultList Model which holds data.I am listening to this Model.When i get ListDataEvent.I got methods like getIndex0(),getIndex1() methods which barely says range of indices changed/removed/added.It Is easy to get Objects when there is change of existing Objects or new one added.Is there any work around you think to get what objects are removed from the Model.


ListDataListener listner1=new ListdataListener(){

public void intervalAdded(ListDataEvent e){
public void intervalRemoved(ListDataEvent e){

public void contentsChanged(ListDataEvent e){
DefaultListModel model=new DefaultListModel();

Sun Certified Java Programmer
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

No... the event is thrown after the data has already been removed from the model, so you can't get them from the model anymore...

If the data is held somewhere else other than the list model, you could iterate through the model and see if there are any extra data values, and you know those are removed...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
That's true...Thanks for your time to clarify me.with your answer i am clear that what am i expected is right.
[ December 24, 2002: Message edited by: Kumar T ]
I agree. Here's the link: http://aspose.com/file-tools
subject: ListDataEvent ...looks Stange...?
It's not a secret anymore!