View Javadoc

1   package nl.tudelft.simulation.introspection.mapping;
2   
3   import java.awt.Color;
4   import java.awt.Component;
5   import java.util.EventObject;
6   
7   import javax.swing.JPanel;
8   import javax.swing.JTable;
9   import javax.swing.event.CellEditorListener;
10  import javax.swing.table.TableCellEditor;
11  
12  /***
13   * An editor for TableObjects.
14   * <p>
15   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
16   * University of Technology </a>, the Netherlands. <br>
17   * See for project information <a
18   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
19   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
20   * General Public License (LGPL) </a>, no warranty.
21   * 
22   * @author <a href="http://www.peter-jacobs.com/index.htm">Peter Jacobs </a>
23   * @version 1.2 Apr 15, 2004
24   * @since 1.5
25   */
26  public class MyTableCellEditor implements TableCellEditor
27  {
28      /***
29       * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(JTable,
30       *      Object, boolean, int, int)
31       */
32      public Component getTableCellEditorComponent(final JTable table,
33              final Object value, final boolean isSelected, final int row,
34              final int column)
35      {
36          JPanel result = new JPanel();
37          result.setBackground(Color.YELLOW);
38          return result;
39      }
40  
41      /***
42       * @see javax.swing.CellEditor#getCellEditorValue()
43       */
44      public Object getCellEditorValue()
45      {
46          return null;
47      }
48  
49      /***
50       * @see javax.swing.CellEditor#isCellEditable(EventObject)
51       */
52      public boolean isCellEditable(final EventObject anEvent)
53      {
54          return false;
55      }
56  
57      /***
58       * @see javax.swing.CellEditor#shouldSelectCell(EventObject)
59       */
60      public boolean shouldSelectCell(final EventObject anEvent)
61      {
62          return false;
63      }
64  
65      /***
66       * @see javax.swing.CellEditor#stopCellEditing()
67       */
68      public boolean stopCellEditing()
69      {
70          return false;
71      }
72  
73      /***
74       * @see javax.swing.CellEditor#cancelCellEditing()
75       */
76      public void cancelCellEditing()
77      {
78          // We cannot edit; this method will never be invoked.
79      }
80  
81      /***
82       * @see javax.swing.CellEditor#addCellEditorListener(CellEditorListener)
83       */
84      public void addCellEditorListener(final CellEditorListener l)
85      {
86          // Strange, we do not edit
87      }
88  
89      /***
90       * @see javax.swing.CellEditor#removeCellEditorListener(CellEditorListener)
91       */
92      public void removeCellEditorListener(final CellEditorListener l)
93      {
94          // Same story
95      }
96  }