1 18 19 package org.objectweb.jac.aspects.gui.swing; 20 21 import java.awt.Dimension ; 22 import java.awt.GridLayout ; 23 import java.awt.Insets ; 24 import javax.swing.BorderFactory ; 25 import javax.swing.BoxLayout ; 26 import javax.swing.JCheckBox ; 27 import javax.swing.JComponent ; 28 import org.objectweb.jac.aspects.gui.FieldUpdate; 29 import org.objectweb.jac.aspects.gui.FieldView; 30 import org.objectweb.jac.core.rtti.FieldItem; 31 32 33 34 public class BooleanViewer extends AbstractFieldView 35 implements FieldView, FieldUpdate 36 { 37 JCheckBox checkBox = new JCheckBox (); 38 39 public BooleanViewer(Boolean value, Object substance, FieldItem field) { 40 super(substance,field); 41 checkBox.setEnabled(false); 42 add(checkBox); 43 } 44 45 public BooleanViewer() { 46 setLayout(new GridLayout (1,1)); 47 checkBox.setVerticalAlignment(JCheckBox.CENTER); 48 checkBox.setHorizontalAlignment(JCheckBox.CENTER); 49 checkBox.setMargin(new Insets (0,0,0,0)); 50 checkBox.setBorder(BorderFactory.createEmptyBorder()); 51 add(checkBox); 52 } 53 54 public void setValue(Object value) { 55 checkBox.setSelected(((Boolean )value).booleanValue()); 56 } 57 58 protected JComponent getComponent() { 59 return checkBox; 60 } 61 62 public Dimension getPreferredSize() { 63 return checkBox.getPreferredSize(); 64 } 65 } 66 | Popular Tags |