KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   Copyright (C) 2001-2003 Laurent Martelli <laurent@aopsys.com>
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 java.awt.Dimension JavaDoc;
22 import java.awt.GridLayout JavaDoc;
23 import java.awt.Insets JavaDoc;
24 import javax.swing.BorderFactory JavaDoc;
25 import javax.swing.BoxLayout JavaDoc;
26 import javax.swing.JCheckBox JavaDoc;
27 import javax.swing.JComponent JavaDoc;
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 JavaDoc checkBox = new JCheckBox JavaDoc();
38
39     public BooleanViewer(Boolean JavaDoc value, Object JavaDoc substance, FieldItem field) {
40         super(substance,field);
41         checkBox.setEnabled(false);
42         add(checkBox);
43     }
44
45     public BooleanViewer() {
46         setLayout(new GridLayout JavaDoc(1,1));
47         checkBox.setVerticalAlignment(JCheckBox.CENTER);
48         checkBox.setHorizontalAlignment(JCheckBox.CENTER);
49         checkBox.setMargin(new Insets JavaDoc(0,0,0,0));
50         checkBox.setBorder(BorderFactory.createEmptyBorder());
51         add(checkBox);
52     }
53     
54     public void setValue(Object JavaDoc value) {
55         checkBox.setSelected(((Boolean JavaDoc)value).booleanValue());
56     }
57
58     protected JComponent JavaDoc getComponent() {
59         return checkBox;
60     }
61
62     public Dimension JavaDoc getPreferredSize() {
63         return checkBox.getPreferredSize();
64     }
65 }
66
Popular Tags