KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > swing > ImageURLViewer


1 /*
2   Copyright (C) 2001-2002 Renaud Pawlak, Laurent Martelli
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.aspects.gui.swing;
20
21 import org.objectweb.jac.aspects.gui.FieldView;
22 import org.objectweb.jac.core.rtti.FieldItem;
23 import java.net.URL JavaDoc;
24 import javax.swing.ImageIcon JavaDoc;
25 import javax.swing.JComponent JavaDoc;
26 import javax.swing.JLabel JavaDoc;
27
28 /**
29  * A Swing viewer component for imageURL values.
30  * @see java.net.URL
31  */

32 public class ImageURLViewer extends AbstractFieldView
33     implements FieldView
34 {
35     JLabel JavaDoc label = new JLabel JavaDoc();
36    
37     /**
38      * Constructs a new imageURL editor.
39      */

40     public ImageURLViewer(URL JavaDoc value, Object JavaDoc substance, FieldItem field) {
41         super(substance,field);
42         setValue(value);
43         add(label);
44     }
45
46     public ImageURLViewer() {
47         add(label);
48     }
49
50     /**
51      * Sets the value of the edited date.
52      *
53      * @param value an URL
54      */

55     public void setValue(Object JavaDoc value) {
56         if (value!=null)
57             label.setIcon(new ImageIcon JavaDoc((URL JavaDoc)value));
58         else
59             label.setIcon(null);
60     }
61
62     protected JComponent JavaDoc getComponent() {
63         return label;
64     }
65 }
66
Popular Tags