Table checkbox in Javafx selects alone when I move the scroll bar

Asked

Viewed 109 times

1

Hello! I am learning javafx and I have a table with a checkbox column, when the application starts it lists right in the rows of the table. The problem is that when I select the first two for example, it selects others on its own, and as I go down the scroll bar each hour is selected. That’s my class with the getters and setters.

 package model.domain;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.property.BooleanProperty;
import javafx.scene.control.CheckBox;



public class op_inicial {

    private SimpleBooleanProperty selecao;
    private String operacao;
    private Double valor;
    private String situacao;
    private Double valorDaParcela;
    private String modalidade;
    private String data_contratacao;



    public op_inicial(String operacao, Double valor, String situacao, Double valorDaParcela, String modalidade, String data_contratacao) {
        this.selecao = new SimpleBooleanProperty(false);
        this.operacao = operacao;
        this.valor = valor;
        this.situacao = situacao;
        this.valorDaParcela = valorDaParcela;
        this.modalidade = modalidade;
        this.data_contratacao = data_contratacao;
    }

    public String getModalidade() {
        return modalidade;
    }

    public void setModalidade(String modalidade) {
        this.modalidade = modalidade;
    }

    public String getData_contratacao() {
        return data_contratacao;
    }

    public void setData_contratacao(String data_contratacao) {
        this.data_contratacao = data_contratacao;
    }


    public op_inicial() {

    }

    public Double getValorDaParcela() {
        return valorDaParcela;
    }

    public void setValorDaParcela(Double valorDaParcela) {
        this.valorDaParcela = valorDaParcela;
    }

    public op_inicial(Double valorDaParcela) {
        this.valorDaParcela = valorDaParcela;
    }

    public Double valorDaParcela (){
        return valorDaParcela;
    }

    public SimpleBooleanProperty getSelecao() {
        return selecao;
    }

    public void setSelecao(SimpleBooleanProperty selecao) {
        this.selecao = selecao;
    }




    public String getOperacao() {
        return operacao;
    }

    public String operacao() {
        return operacao;
    }

    public void setOperacao(String operacao) {
        this.operacao = operacao;

    }

    public Double getValor() {
        return valor;
    }

    public Double valor() {
        return valor;
    }

    public void setValor(Double valor) {
        this.valor = valor;

    }

    public String getSituacao() {
        return situacao;
    }

    public String situacao() {
        return situacao;
    }

    public void setSituacao(String situacao) {
        this.situacao = situacao;

    }

}

And here I mount the table, I’m using Scene Builder. I’m populating the table with an array list that I take from a system. The table mounts correctly with the checkbox, but at the time of selecting it gets this error and when I organize a column by higher value the checkbox column does not order along with the others. If anyone can help me please :))))).

 public void preencheTabelas(TextField txtChave, String mci) throws PropertyVetoException, Throwable {

        try {

            listop = captura_sistema.operacoes(txtChave, mci);

            //=============  primeira tabela  =========
            coluna_check_selecao1.setCellFactory(CheckBoxTableCell.forTableColumn(coluna_check_selecao1));
            coluna_check_selecao1.setCellValueFactory(new PropertyValueFactory<>("selecao"));
            coluna_Operacao1.setCellValueFactory(new PropertyValueFactory<>("operacao"));
            coluna_valorParcela1.setCellValueFactory(new PropertyValueFactory<>("valorDaParcela"));
            coluna_Valor1.setCellValueFactory(new PropertyValueFactory<>("valor"));
            coluna_situacao1.setCellValueFactory(new PropertyValueFactory<>("situacao"));
            coluna_Modalidade1.setCellValueFactory(new PropertyValueFactory<>("modalidade"));
            coluna_DataContratacao1.setCellValueFactory(new PropertyValueFactory<>("data_contratacao"));

            observableListOperacao = FXCollections.observableArrayList(listop);

            tableOperacoes.setItems(observableListOperacao);
  • can add part of the code where you declared the variables and types of tableView and tableColumns???

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.