Editable JTable Tutorial

前端 未结 6 790
名媛妹妹
名媛妹妹 2021-01-31 06:09

Are there any good books or website that go over creating a JTable? I want to make one column editable. I would like to actually put a inherited JCheckBox

6条回答
  •  被撕碎了的回忆
    2021-01-31 07:13

    If you are trying to use a simple JTable with 1 column editable and you know the column location you could always use default table model and overload the isCellEditable call.

    something like this :

    myTable.setModel(new DefaultTableModel(){
    @Override
    public boolean isCellEditable(int row, int column) {
        if (column == x) {
            return true;
        } else
            return false;
    }
    });
    

    And for the check box create a renderer class

    MyCheckBoxRenderer extends JCheckBox implements TableCellRenderer
    

提交回复
热议问题