1 7 8 package org.jdesktop.swing.binding; 9 10 import org.jdesktop.swing.data.DataModel; 11 import org.jdesktop.swing.data.MetaData; 12 13 import org.jdesktop.swing.JXRadioGroup; 14 15 import java.awt.event.ActionEvent ; 16 import java.awt.event.ActionListener ; 17 18 import javax.swing.JComponent ; 19 20 21 27 public class RadioBinding extends AbstractBinding { 28 private JXRadioGroup radioGroup; 29 30 public RadioBinding(JXRadioGroup radioGroup, 31 DataModel dataModel, String fieldName) { 32 super(radioGroup, dataModel, fieldName, Binding.AUTO_VALIDATE_NONE); 33 } 34 35 public JComponent getComponent() { 36 return radioGroup; 37 } 38 39 protected void setComponent(JComponent component) { 40 radioGroup = (JXRadioGroup) component; 41 radioGroup.addActionListener(new ActionListener () { 42 public void actionPerformed(ActionEvent e) { 43 if (!pulling) { 44 setModified(true); 45 } 46 } 47 }); 48 } 49 50 protected Object getComponentValue(){ 51 return radioGroup.getSelectedValue(); 52 } 53 54 protected void setComponentValue(Object value) { 55 radioGroup.setSelectedValue(value); 56 } 57 58 } 59 | Popular Tags |