KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   Copyright (C) 2001 Renaud Pawlak
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 javax.swing.JComponent JavaDoc;
24 import javax.swing.JTextArea JavaDoc;
25
26 /**
27  * A Swing viewer for texts.
28  */

29
30 public class TextViewer extends AbstractFieldView
31    implements FieldView
32 {
33    JTextArea JavaDoc textArea = new JTextArea JavaDoc();
34
35    public TextViewer(Object JavaDoc value, Object JavaDoc substance, FieldItem field) {
36       super(substance,field);
37       textArea.setEditable(false);
38       textArea.setLineWrap(true);
39       setValue(value);
40       add(textArea);
41    }
42
43    public void setValue(Object JavaDoc text) {
44       if( text == null ) {
45          textArea.setText("");
46       } else {
47          textArea.setText(text.toString());
48       }
49    }
50
51    public Object JavaDoc getValue() {
52       return textArea.getText();
53    }
54
55    protected JComponent JavaDoc getComponent() {
56       return textArea;
57    }
58 }
59
60
Popular Tags