01: /*
02: * StringCellEditor.java
03: *
04: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: */
21:
22: package org.underworldlabs.swing.table;
23:
24: import javax.swing.JTextField;
25: import org.underworldlabs.Constants;
26:
27: /* ----------------------------------------------------------
28: * CVS NOTE: Changes to the CVS repository prior to the
29: * release of version 3.0.0beta1 has meant a
30: * resetting of CVS revision numbers.
31: * ----------------------------------------------------------
32: */
33:
34: /**
35: * Simple string value table column cell editor.
36: *
37: * @author Takis Diakoumis
38: * @version $Revision: 1.6 $
39: * @date $Date: 2006/07/16 15:45:52 $
40: */
41: public class StringCellEditor extends JTextField implements
42: TableCellEditorValue {
43:
44: public StringCellEditor() {
45: super ();
46: setBorder(null);
47: setHorizontalAlignment(JTextField.LEFT);
48: }
49:
50: /**
51: * Returns the current editor value from the component
52: * defining this object.
53: *
54: * @return the editor's value
55: */
56: public String getEditorValue() {
57: return getText();
58: }
59:
60: /**
61: * Resets the editor's value to an empty string.
62: */
63: public void resetValue() {
64: setText(Constants.EMPTY);
65: }
66:
67: /**
68: * Returns the current editor value string.
69: */
70: public String getValue() {
71: return getText();
72: }
73:
74: /**
75: * Sets the editor's value to that specified.
76: *
77: * @param value - the value to be set
78: */
79: public void setValue(String value) {
80: setText(value);
81: }
82:
83: }
|