Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / data / feature / swing / table / TextAreaCellEditor.java @ 25909

History | View | Annotate | Download (2.12 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) 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., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {{Task}}
26
 */
27
package org.gvsig.fmap.data.feature.swing.table;
28

    
29
import javax.swing.*;
30

    
31
/**
32
 * <p>
33
 * Taken and adapted from the Article <strong>"Multi-line cells in JTable in JDK
34
 * 1.4+"</strong> by Dr. Heinz M. Kabutz:
35
 * </p>
36
 * <p>
37
 * http://www.javaspecialists.eu/archive/Issue106.html
38
 * </p>
39
 * 
40
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
41
 */
42
public class TextAreaCellEditor extends DefaultCellEditor {
43

    
44
    private static final long serialVersionUID = -5614806192749314509L;
45

    
46
    @SuppressWarnings("serial")
47
    public TextAreaCellEditor() {
48
        super(new JTextField());
49
        final JTextArea textArea = new JTextArea();
50
        textArea.setWrapStyleWord(true);
51
        textArea.setLineWrap(true);
52
        JScrollPane scrollPane = new JScrollPane(textArea);
53
        scrollPane.setBorder(null);
54
        editorComponent = scrollPane;
55

    
56
        delegate = new DefaultCellEditor.EditorDelegate() {
57
            public void setValue(Object value) {
58
                textArea.setText((value != null) ? value.toString() : "");
59
            }
60

    
61
            public Object getCellEditorValue() {
62
                return textArea.getText();
63
            }
64
        };
65
    }
66
}