Hi all, I have a JList that is displaying a DefaultListModel that is populated via the press of a button. The model is initially empty. I have also declared a variable outside of valueChanged that I need to reset inside the valueChanged method. Here are the pertinent parts of my code:
I know the model is populated because I do a S.o.p and the elements print out as expected. However, when I click on one of the lines in the JList getSelectedValue() returns null. Any hints would be greatly appreciated! Bill
They that can give up essential liberty to obtain a little temporary safety<BR>deserve neither liberty nor safety.<BR> --Benjamin Franklin
Hi, That's because you did not select any item from the list. getSelectedValue() looks for a selected item and return that Object, when never find a selected item will return null... Regards
Qusay
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: JList valueChanged not recognizing DefaultListModel