-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuppButtonEditor.java
More file actions
53 lines (38 loc) · 1.18 KB
/
SuppButtonEditor.java
File metadata and controls
53 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package formulaireProject;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JTable;
public class SuppButtonEditor extends DefaultCellEditor {
private JButton button;
private SuppButtonListener blistener = new SuppButtonListener();
public SuppButtonEditor(JCheckBox checkBox) {
super(checkBox);
button = new JButton();
button.setOpaque(true);
button.addActionListener(blistener);
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isEditable, int row, int col){
blistener.setRow(row);
blistener.setTable(table);
button.setText((value == null) ? "" : value.toString());
return button;
}
private class SuppButtonListener implements ActionListener{
private int row;
private JTable table;
public void setRow(int row) {
this.row = row;
}
public void setTable(JTable table) {
this.table = table;
}
public void actionPerformed(ActionEvent event) {
if(table.getRowCount() > 0)
((Tableau)table.getModel()).deleteRow(this.row);
}
}
}