~sword-devel/jsword/trunk

« back to all changes in this revision

Viewing changes to jsword/java/common/org/crosswire/common/config/swing/fields/ActionField.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.fields;
3
 
 
4
 
import java.awt.BorderLayout;
5
 
import java.awt.event.ActionEvent;
6
 
import java.awt.event.ActionListener;
7
 
 
8
 
import javax.swing.JButton;
9
 
import javax.swing.JComponent;
10
 
import javax.swing.JPanel;
11
 
 
12
 
import org.crosswire.common.config.swing.Field;
13
 
 
14
 
/**
15
 
* A Filename selection.
16
 
*
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}>
35
 
* @author Joe Walker
36
 
*/
37
 
public class ActionField extends JPanel implements Field
38
 
{
39
 
    /**
40
 
    * Create a new FileField
41
 
    */
42
 
    public ActionField()
43
 
    {
44
 
        edit.addActionListener(new ActionListener()
45
 
        {
46
 
            public void actionPerformed(ActionEvent ex) { runner.run(); }
47
 
        });
48
 
 
49
 
        setLayout(new BorderLayout());
50
 
        add("West", edit);
51
 
    }
52
 
 
53
 
    /**
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
58
 
    */
59
 
    public void setOptions(Object param)
60
 
    {
61
 
        Object[] params = (Object[]) param;
62
 
        runner = (Runnable) params[0];
63
 
        edit.setText((String) params[1]);
64
 
    }
65
 
 
66
 
    /**
67
 
    * Return a string version of the current value
68
 
    * @return The current value
69
 
    */
70
 
    public String getValue()
71
 
    {
72
 
        return "";
73
 
    }
74
 
 
75
 
    /**
76
 
    * Set the current value
77
 
    * @param value The new text
78
 
    */
79
 
    public void setValue(String value)
80
 
    {
81
 
    }
82
 
 
83
 
    /**
84
 
    * Get the actual component that we can add to a Panel.
85
 
    * (This can well be this in an implementation).
86
 
    */
87
 
    public JComponent getComponent()
88
 
    {
89
 
        return this;
90
 
    }
91
 
 
92
 
    /** What to do when we are clicked */
93
 
    protected Runnable runner;
94
 
 
95
 
    /** The browse button */
96
 
    private JButton edit = new JButton("Edit");
97
 
}
98