I have this JList (say MyList) in a JFrame. Im using Netbeans6 GUI builder and I've set a binding for this list.
When run, the binding works fine, and MyList is populated correctly.
Now, what im looking for is a way to add more data to this list from another text box on a button Click. But the problem exists here :
W/o binding i would extract the ListModel for the JList using "getModel()" function and add element to it using "addElement()".
However, when im using Binding. and i try to extract the ListModel and Map it to DefaultListModel i get the following exception:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: org.jdesktop.swingbinding.JListBinding$BindingListModel cannot be cast to javax.swing.DefaultListModel
So my question is , how do i add more elements to MyList which is already bound to some other dataSource ?
Anyone has any clues ? Any Help will greatly appreciated!!
Thanks!
You have to modify the List to which the JList is bound. And this List must be an Observable list for the change to be registered. The point of binding is that you don't manipulate components' models anymore, but their underlaying data types instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With