Java 11 integration;
[jalview.git] / src2 / fr / orsay / lri / varna / components / ActionEditor.java
1 package fr.orsay.lri.varna.components;
2
3 import java.awt.Component;
4 import java.awt.Event;
5 import java.awt.event.ActionListener;
6 import java.util.EventObject;
7
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;
14
15 public class ActionEditor extends AbstractCellEditor implements TableCellEditor { 
16
17         JButton _btn = new JButton();
18
19         public ActionEditor (ActionListener a) {
20           // add all elments you need to your panel
21           _btn.addActionListener(a);
22         }
23
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
29            
30            return _btn;
31         }
32         public Object getCellEditorValue() 
33         { 
34                 return ""; 
35         } 
36         
37         public boolean shouldSelectCell(EventObject anEvent)
38         {
39                 return super.shouldSelectCell(anEvent);
40                 
41         }
42
43         public boolean isCellEditable(EventObject anEvent)
44         {
45                 return super.isCellEditable(anEvent);           
46         }
47         
48         public boolean stopCellEditing()
49         {
50                 return super.stopCellEditing();
51         }
52
53         
54