2
package org.crosswire.common.config.swing;
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.Choice;
12
import org.crosswire.common.util.Convert;
15
* Allow the user to choose from True/False.
17
* <p><table border='1' cellPadding='3' cellSpacing='0'>
18
* <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
20
* Distribution Licence:<br />
21
* JSword is free software; you can redistribute it
22
* and/or modify it under the terms of the GNU General Public License,
23
* version 2 as published by the Free Software Foundation.<br />
24
* This program is distributed in the hope that it will be useful,
25
* but WITHOUT ANY WARRANTY; without even the implied warranty of
26
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27
* General Public License for more details.<br />
28
* The License is available on the internet
29
* <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
30
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
31
* MA 02111-1307, USA<br />
32
* The copyright to this program is held by it's authors.
33
* </font></td></tr></table>
35
* @author Joe Walker [joe at eireneh dot com]
38
public class BooleanField extends JPanel implements Field
41
* Give the values list (true/false) to the ComboBox
45
ButtonGroup group = new ButtonGroup();
49
setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
55
* Some fields will need some extra info to display properly
56
* like the options in an options field. FieldMap calls this
57
* method with options provided by the choice.
58
* @param param The options provided by the Choice
60
public void setChoice(Choice param)
65
* Return a string for use in the properties file
66
* @return The current value
68
public String getValue()
70
return (String) Convert.boolean2String(on.isSelected());
74
* Set the current value
75
* @param value The new text
77
public void setValue(String value)
79
on.setSelected(Convert.string2Boolean(value));
80
off.setSelected(!Convert.string2Boolean(value));
84
* Get the actual component that we can add to a Panel.
85
* (This can well be this in an implementation).
87
public JComponent getComponent()
92
/** The 'on' button */
93
private JRadioButton on = new JRadioButton("Yes");
95
/** The 'off' button */
96
private JRadioButton off = new JRadioButton("No");