KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > InputCheckboxControl


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 /*
22  * Created on Jan 15, 2006
23  */

24 package org.lobobrowser.html.renderer;
25
26 import org.lobobrowser.html.domimpl.*;
27 import org.lobobrowser.util.gui.WrapperLayout;
28 import javax.swing.*;
29
30 class InputCheckboxControl extends BaseInputControl {
31     private final JCheckBox widget;
32     
33     public InputCheckboxControl(HTMLBaseInputElement modelNode) {
34         super(modelNode);
35         this.setLayout(WrapperLayout.getInstance());
36         JCheckBox checkBox = new JCheckBox();
37         checkBox.setOpaque(false);
38         this.widget = checkBox;
39         this.add(checkBox);
40     }
41     
42     public void reset(int availWidth, int availHeight) {
43         super.reset(availWidth, availHeight);
44         String JavaDoc checkedText = this.controlElement.getAttribute("checked");
45         this.widget.setSelected("checked".equalsIgnoreCase(checkedText));
46     }
47     
48     /* (non-Javadoc)
49      * @see org.xamjwg.html.domimpl.InputContext#click()
50      */

51     public void click() {
52         this.widget.doClick();
53     }
54
55     /* (non-Javadoc)
56      * @see org.xamjwg.html.domimpl.InputContext#getChecked()
57      */

58     public boolean getChecked() {
59         return this.widget.isSelected();
60     }
61
62     /* (non-Javadoc)
63      * @see org.xamjwg.html.domimpl.InputContext#setChecked(boolean)
64      */

65     public void setChecked(boolean checked) {
66         this.widget.setSelected(checked);
67     }
68
69     /* (non-Javadoc)
70      * @see org.xamjwg.html.domimpl.InputContext#setDisabled(boolean)
71      */

72     public void setDisabled(boolean disabled) {
73         super.setDisabled(disabled);
74         this.widget.setEnabled(!disabled);
75     }
76     
77     public void resetInput() {
78         String JavaDoc checkedText = this.controlElement.getAttribute("checked");
79         this.widget.setSelected("checked".equalsIgnoreCase(checkedText));
80     }
81     
82     public String JavaDoc getValue() {
83         return this.controlElement.getAttribute("value");
84     }
85 }
86
Popular Tags