2
package org.crosswire.common.config.swing.fields;
4
import java.awt.FlowLayout;
6
import javax.swing.ButtonGroup;
7
import javax.swing.JComponent;
8
import javax.swing.JPanel;
9
import javax.swing.JRadioButton;
11
import org.crosswire.common.config.swing.Field;
12
import org.crosswire.common.util.Convert;
15
* Allow the user to choose from True/False.
17
* <table border='1' cellPadding='3' cellSpacing='0' width="100%">
18
* <tr><td bgColor='white'class='TableRowColor'><font size='-7'>
19
* Distribution Licence:<br />
20
* Project B is free software; you can redistribute it
21
* and/or modify it under the terms of the GNU General Public License,
22
* version 2 as published by the Free Software Foundation.<br />
23
* This program is distributed in the hope that it will be useful,
24
* but WITHOUT ANY WARRANTY; without even the implied warranty of
25
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26
* General Public License for more details.<br />
27
* The License is available on the internet
28
* <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, by writing to
29
* <i>Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30
* MA 02111-1307, USA</i>, Or locally at the Licence link below.<br />
31
* The copyright to this program is held by it's authors.
32
* </font></td></tr></table>
33
* @see <a href='http://www.eireneh.com/servlets/Web'>Project B Home</a>
34
* @see <{docs.Licence}>
37
public class BooleanField extends JPanel implements Field
40
* Give the values list (true/false) to the ComboBox
44
ButtonGroup group = new ButtonGroup();
48
setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
54
* Some fields will need some extra info to display properly
55
* like the options in an options field. FieldMap calls this
56
* method with options provided by the choice.
57
* @param param The options provided by the Choice
59
public void setOptions(Object param)
64
* Return a string for use in the properties file
65
* @return The current value
67
public String getValue()
69
return (String) Convert.boolean2String(on.isSelected());
73
* Set the current value
74
* @param value The new text
76
public void setValue(String value)
78
on.setSelected(Convert.string2Boolean(value));
79
off.setSelected(!Convert.string2Boolean(value));
83
* Get the actual component that we can add to a Panel.
84
* (This can well be this in an implementation).
86
public JComponent getComponent()
91
/** The 'on' button */
92
private JRadioButton on = new JRadioButton("Yes");
94
/** The 'off' button */
95
private JRadioButton off = new JRadioButton("No");