1 17 18 package org.objectweb.jac.aspects.gui.swing; 19 20 21 import java.net.URL ; 22 import javax.swing.BoxLayout ; 23 import javax.swing.ImageIcon ; 24 import javax.swing.JComponent ; 25 import javax.swing.JLabel ; 26 import org.objectweb.jac.aspects.gui.FieldEditor; 27 import org.objectweb.jac.aspects.gui.Length; 28 import org.objectweb.jac.core.rtti.FieldItem; 29 30 33 34 public class ImageURLEditor extends AbstractFieldEditor 35 implements FieldEditor 36 { 37 38 protected JLabel image; 39 protected URLEditor urlEditor; 40 41 44 public ImageURLEditor(Object substance, FieldItem field) { 45 super(substance,field); 46 setLayout( new BoxLayout ( this, BoxLayout.Y_AXIS ) ); 47 image = new JLabel (); 48 urlEditor = new URLEditor(substance,field); 49 add(image); 50 add(urlEditor); 51 } 52 53 public void setValue(Object value) { 54 urlEditor.setValue(value); 55 image.setIcon(value != null ? new ImageIcon ((URL )value) : null); 56 } 57 58 public Object getValue() { 59 return urlEditor.getValue(); 60 } 61 62 public void setSize(Length width, Length height) { 63 super.setSize(width,height); 64 urlEditor.setSize(width,height); 65 } 66 67 public void onSetFocus(Object extra) { 68 urlEditor.onSetFocus(extra); 69 } 70 71 protected JComponent getComponent() { 72 return urlEditor; 73 } 74 } 75 | Popular Tags |