Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_controls / src / org / gvsig / fmap / mapcontrol / dal / feature / swing / table / TextAreaCellEditor.java @ 31616

History | View | Annotate | Download (2.22 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (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.mapcontrol.dal.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
    private final JTextArea textArea;
47

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

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

    
63
            public Object getCellEditorValue() {
64
                return textArea.getText();
65
            }
66
        };
67
    }
68
    
69
    public JTextArea getTextArea() {
70
        return textArea;
71
    }
72
}