1 18 19 package org.objectweb.jac.aspects.gui.swing; 20 21 import javax.swing.JComponent ; 22 import javax.swing.JLabel ; 23 import org.objectweb.jac.aspects.gui.FieldView; 24 import org.objectweb.jac.aspects.gui.Format; 25 import org.objectweb.jac.core.rtti.FieldItem; 26 27 30 31 public abstract class FormatViewer extends AbstractFieldView 32 implements FieldView 33 { 34 35 protected Format format; 36 protected JLabel label = new JLabel (); 37 38 40 41 public FormatViewer(Object value, Object substance, FieldItem field) { 42 super(substance,field); 43 initFormat(field); 44 setValue(value); 45 add(label); 46 } 47 48 public FormatViewer() { 49 setTableFont(); 50 setLayout(); 51 add(label); 52 } 53 54 protected abstract void initFormat(FieldItem field); 55 56 protected void setLayout() { 57 } 58 59 public void setField(FieldItem field) { 60 super.setField(field); 61 initFormat(field); 62 } 63 64 66 public void setValue(Object value) { 67 if (value!=null) 68 label.setText(format.format(value)); 69 else 70 label.setText(""); 71 } 72 73 protected JComponent getComponent() { 74 return label; 75 } 76 } 77 | Popular Tags |