1. 程式人生 > >JTable的列中新增JCheckBox元件

JTable的列中新增JCheckBox元件

class MyTableRenderer extends JCheckBox implements TableCellRenderer {
 // 此方法可以查考JDK文件的說明
 public Component getTableCellRendererComponent(JTable table, Object value,
   boolean isSelected, boolean hasFocus, int row, int column) {
  Boolean b = (Boolean) value;
  this.setSelected(b.booleanValue());
  return this;
 }
}