Java JList Update Using BeanBinding Netbeans

I have this JList (say MyList) in a JFrame. I am using Netbeans6 GUI builder and I have set the binding for this list.

At startup, the binding works fine, and MyList populates correctly.

Now what I'm looking for is a way to add more data to this list from another text box when I click a button. But the problem exists here:

Binding w / o I would retrieve the ListModel for the JList using the function "getModel ()" and add an element to it using "addElement ()".

However, when im uses 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 to add more elements to MyList that are already bound to another data source?

Does anyone have any clues? Any help would be greatly appreciated!

Thanks!

+3
source share
1 answer

You need to change the list to which the JList is bound. And this list should be a list of changes observed for recording. The anchor point is that you no longer manipulate component models, but instead subtopics.

+2
source

Source: https://habr.com/ru/post/1709308/


All Articles