~sword-devel/jsword/trunk

« back to all changes in this revision

Viewing changes to jsword/java/common/org/crosswire/common/config/swing/NumberField.java

  • Committer: joe
  • Date: 2002-10-08 21:36:18 UTC
  • Revision ID: svn-v4:a88caf3b-7e0a-0410-8d0d-cecb45342206:trunk:80
big config and comment update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
package org.crosswire.common.config.swing;
 
3
 
 
4
import java.awt.BorderLayout;
 
5
 
 
6
import javax.swing.JComponent;
 
7
import javax.swing.JPanel;
 
8
import javax.swing.JTextField;
 
9
 
 
10
import org.crosswire.common.config.Choice;
 
11
import org.crosswire.common.swing.NumericDocument;
 
12
 
 
13
/**
 
14
 * A PropertyNumberField is a PropertyTextField that only
 
15
 * stores numbers.
 
16
 * 
 
17
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 
18
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 
19
 *
 
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>
 
34
 * @see docs.Licence
 
35
 * @author Joe Walker [joe at eireneh dot com]
 
36
 * @version $Id$
 
37
 */
 
38
public class NumberField extends JPanel implements Field
 
39
{
 
40
    /**
 
41
     * Create a new FileField
 
42
     */
 
43
    public NumberField()
 
44
    {
 
45
        text.setDocument(new NumericDocument());
 
46
        text.setColumns(10);
 
47
 
 
48
        setLayout(new BorderLayout(10, 0));
 
49
        add("West", text);
 
50
    }
 
51
 
 
52
    /**
 
53
     * Some fields will need some extra info to display properly
 
54
     * like the options in an options field. FieldMap calls this
 
55
     * method with options provided by the choice.
 
56
     * @param param The options provided by the Choice
 
57
     */
 
58
    public void setChoice(Choice param)
 
59
    {
 
60
    }
 
61
 
 
62
    /**
 
63
     * Return a string version of the current value
 
64
     * @return The current value
 
65
     */
 
66
    public String getValue()
 
67
    {
 
68
        return text.getText();
 
69
    }
 
70
 
 
71
    /**
 
72
     * Set the current value
 
73
     * @param value The new text
 
74
     */
 
75
    public void setValue(String value)
 
76
    {
 
77
        text.setText(value);
 
78
    }
 
79
 
 
80
    /**
 
81
     * Get the actual component that we can add to a Panel.
 
82
     * (This can well be this in an implementation).
 
83
     */
 
84
    public JComponent getComponent()
 
85
    {
 
86
        return this;
 
87
    }
 
88
 
 
89
    /** The text field */
 
90
    private JTextField text = new JTextField();
 
91
}
 
92