Class JListWiringHarness

java.lang.Object
com.palantir.ptoss.cinch.swing.JListWiringHarness
All Implemented Interfaces:
WiringHarness<Bound,Field>

public class JListWiringHarness extends Object implements WiringHarness<Bound,Field>

Wires up a JList to a List in a BindableModel. Whenever the contents of the bound List change (and the BindableModel's update is called) the JList's model will be swapped out with a new model with the new contents. Selection of values is maintained between model swaps.

This bindings is only one way. The JList will modify itself to reflect the contents of the List in the BindableModel. However, changes to the JList's model after that will not be reflected in the model. The idea here is that if the user takes some action to remove an item from the list then that should be accomplished by removing an item from the underlying BindableModel, not the JList.

Implementation notes: a DefaultTableModel is used to back the JList. Maintaining selection between model swaps is simply done with Object.equals(Object) comparisons.