1 package fr.orsay.lri.varna.components;
3 import java.awt.Component;
5 import java.awt.event.ActionListener;
6 import java.util.EventObject;
8 import javax.swing.AbstractCellEditor;
9 import javax.swing.JButton;
10 import javax.swing.JComponent;
11 import javax.swing.JPanel;
12 import javax.swing.JTable;
13 import javax.swing.table.TableCellEditor;
15 public class ActionEditor extends AbstractCellEditor implements TableCellEditor {
17 JButton _btn = new JButton();
19 public ActionEditor (ActionListener a) {
20 // add all elments you need to your panel
21 _btn.addActionListener(a);
24 public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int vColIndex) {
25 _btn.setText(value.toString());
26 _btn.setActionCommand(value.toString()+"-"+rowIndex);
27 // set all elemnts of you panel to the according values
28 // or add dynamically an action listener
32 public Object getCellEditorValue()
37 public boolean shouldSelectCell(EventObject anEvent)
39 return super.shouldSelectCell(anEvent);
43 public boolean isCellEditable(EventObject anEvent)
45 return super.isCellEditable(anEvent);
48 public boolean stopCellEditing()
50 return super.stopCellEditing();