1 19 20 package org.objectweb.jac.aspects.gui.swing; 21 22 import java.awt.event.ItemEvent ; 23 import java.awt.event.ItemListener ; 24 import javax.swing.JCheckBox ; 25 import org.objectweb.jac.aspects.gui.FieldEditor; 26 import org.objectweb.jac.core.rtti.FieldItem; 27 import org.objectweb.jac.util.ExtBoolean; 28 29 32 33 public class BooleanEditor extends AbstractFieldEditor 34 implements FieldEditor, ItemListener 35 { 36 JCheckBox checkBox = new JCheckBox (); 37 38 41 public BooleanEditor(Object substance, FieldItem field) { 42 super(substance,field); 43 checkBox.addFocusListener(this); 44 checkBox.addItemListener(this); 45 add(checkBox); 46 } 47 48 public Object getValue() { 49 return ExtBoolean.valueOf(checkBox.isSelected()); 50 } 51 52 public void setValue(Object value) { 53 super.setValue(value); 54 checkBox.setSelected(((Boolean )value).booleanValue()); 55 } 56 57 60 public void requestFocus() { 61 checkBox.requestFocus(); 62 loggerFocus.debug("focusing "+checkBox.getClass().getName()); 63 } 64 65 67 public void itemStateChanged(ItemEvent event) { 68 loggerEvents.debug("itemStateChanged on "+this); 69 if (field!=null && isEmbedded) { 70 invokeInContext(this,"commit", new Object []{}); 71 } else { 72 loggerEvents.debug("ignoring item event"); 73 } 74 } 75 } 76 77 | Popular Tags |