1 7 8 package org.jdesktop.swing.binding; 9 10 import javax.swing.JComponent ; 11 import javax.swing.JList ; 12 13 import org.jdesktop.swing.data.DataModelToListModelAdapter; 14 import org.jdesktop.swing.data.SelectionModel; 15 import org.jdesktop.swing.data.TabularDataModel; 16 17 23 public class DirectListBinding extends AbstractBinding { 24 25 private JList list; 26 27 28 public DirectListBinding(JList list, TabularDataModel model, String displayFieldName, SelectionModel sm) { 29 super(list, model, displayFieldName, AbstractBinding.AUTO_VALIDATE_NONE); 30 new ListSelectionBinding(sm, list.getSelectionModel()); 32 list.setModel(new DataModelToListModelAdapter(model, displayFieldName)); 34 } 35 36 public boolean isModified() { 37 return false; 38 } 39 40 public boolean isValid() { 41 return true; 42 } 43 44 public JComponent getComponent() { 45 return list; 46 } 47 48 protected void setComponent(JComponent component) { 49 list = (JList )component; 50 } 51 52 protected Object getComponentValue(){ 53 return null; 54 } 55 56 protected void setComponentValue(Object value) { 57 } 58 } 59 60 | Popular Tags |