01: package com.xoetrope.carousel.services.table;
02:
03: import java.awt.Component;
04: import javax.swing.DefaultCellEditor;
05: import javax.swing.JLabel;
06: import javax.swing.JTable;
07: import javax.swing.JTextField;
08:
09: /**
10: * Custom DefaultCellEditor for a table which does not allow editing of the
11: * first column
12: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
13: * the GNU Public License (GPL), please see license.txt for more details. If
14: * you make commercial use of this software you must purchase a commercial
15: * license from Xoetrope.</p>
16: * <p> $Revision: 1.2 $</p>
17: * @author val
18: */
19: public class RouteTableCellEditor extends DefaultCellEditor {
20:
21: /**
22: * Creates a new instance of RouteTableCellEditor
23: */
24: public RouteTableCellEditor(JTextField textField) {
25: super (textField);
26: }
27:
28: /**
29: * Return the appropriate cell editor component depending on the active column
30: * If it is column 1 return whatever the super class uses otherwise return a
31: * read only label
32: * @param table The JTable being edited
33: * @param value the current value of the cell
34: * @param isSelected whether the content should be selected
35: * @param row the index of the row being edited
36: * @param column the index of the column being edited
37: * @return the appropriate component
38: */
39: public Component getTableCellEditorComponent(JTable table,
40: Object value, boolean isSelected, int row, int column) {
41: if (column == 1)
42: return super .getTableCellEditorComponent(table, value,
43: isSelected, row, column);
44: else
45: return new JLabel(value.toString());
46: }
47:
48: }
|