https://github.com/teerjk/VarSifter
Tip revision: b94de1ca7c0315b5c2e1f080d1407127757b576a authored by Jamie K. Teer on 24 November 2015, 14:45:14 UTC
Version 1.8
Version 1.8
Tip revision: b94de1c
JRadioButtonCellEditor.java
import javax.swing.*;
import javax.swing.table.*;
import java.awt.Component;
import java.awt.event.*;
/**
* Custom Editor to handle JRadioButton (as itself, not as string)
*/
public class JRadioButtonCellEditor extends AbstractCellEditor implements TableCellEditor,ItemListener {
private JRadioButton rB;
public JRadioButtonCellEditor() {
}
public Object getCellEditorValue() {
rB.removeItemListener(this);
return rB;
}
public Component getTableCellEditorComponent(JTable t,
Object value,
boolean isSelected,
int row,
int col) {
rB = (JRadioButton)value;
rB.addItemListener(this);
rB.setHorizontalAlignment(SwingConstants.CENTER);
return rB;
}
public void itemStateChanged (ItemEvent e) {
super.fireEditingStopped();
}
}