문제

i´m trying to put a checkbox in a column in my table...but i shows de boolean value, when i click over the cell, it shows the checkbox and sooner show the boolean value...

    public class Tabela {

    private JTable tabela;
    private JCheckBox checkbox;

    public Tabela(Object[][] linhas, String[] nomeColunas) {    
        this.tabela = new JTable();
        this.tabela.setModel(new DefaultTableModel(linhas, nomeColunas));
        this.checkbox = new JCheckBox();
        this.tabela.setFillsViewportHeight(true);
        this.tabela.getColumn("Selecione").setCellEditor(
              new DefaultCellEditor(checkbox));    
    }

    public JTable getTabela() {    
        return tabela;    
    }    
}

So what´s wrong with my code?

I create seppareted my form, table and panel...

도움이 되었습니까?

해결책

You must override getColumnClass(...) and return Boolean.class for the column that should display the checkboxes. The data model will need to hold Boolean objects for that column as well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top