Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jtable在baund observablelist中添加all后不显示数据_Java_Swing_Binding_Jtable_Observablelist - Fatal编程技术网

Java Jtable在baund observablelist中添加all后不显示数据

Java Jtable在baund observablelist中添加all后不显示数据,java,swing,binding,jtable,observablelist,Java,Swing,Binding,Jtable,Observablelist,我对一个叫做EntradaMercadoriaList的对象的可观察列表的jtable边界有一些困难。添加此列表中的所有对象后,jtable仅显示与列表大小相等的空行 这是我的密码: List <EntradaMercadoria> merc = new ArrayList<EntradaMercadoria>(); for (int i = 0; i < entradasList.size(); i++) { int nf

我对一个叫做EntradaMercadoriaList的对象的可观察列表的jtable边界有一些困难。添加此列表中的所有对象后,jtable仅显示与列表大小相等的空行

这是我的密码:

List <EntradaMercadoria> merc = new ArrayList<EntradaMercadoria>();
        for (int i = 0; i < entradasList.size(); i++) {

            int nf = entradasList.get(i).getDocOrigem();
            int tipo = entradasList.get(i).getTipoDocOrigem().getIdesPecasTipoOrigem();
            String fornecedor = "não-aplicado";
            if (tipo == 2) {
                NfTerc nfTerc;
                nfTerc = entityManager.find(NfTerc.class, entradasList.get(i).getDocOrigem());
                fornecedor = nfTerc.getFornecedoresNumForn().getNumForn() + " - " + nfTerc.getFornecedoresNumForn().getCodPessoa().getNomePessoa();
            }
            boolean novo = true;
            for (int j = 0; j < merc.size(); j++) {
                if (nf == merc.get(j).getnDoc() && fornecedor.equals(merc.get(j).getFornecedor())) {
                    merc.get(j).setQuantidade(merc.get(j).getQuantidade() + 1.00);
                    novo = false;
                }
            }
            if (novo) {
                EntradaMercadoria em = new EntradaMercadoria();
                em.setDataEmissao(entradasList.get(i).getDataOrigem());
                em.setFornecedor(fornecedor);
                em.setQuantidade(1.00);
                em.setTipoDoc(tipo);
                em.setnDoc(nf);
                merc.add(em);
            }

        }
        entradaMercadoriaList.clear();
        entradaMercadoriaList.addAll(merc);
怎么了?是否有方法刷新表格以行显示数据


谢谢。

您使用的是什么
TableModel
?考虑一下吧。在您提供的代码中,您没有可观察列表,您的列表必须位于可观察组件中,例如
模型
,作为
表格模型
的绑定属性,并且当您调用
集合列表
时,您会向观察者触发状态更改。没有声明的模型,我用netbeans创建了它,并用这个jtable绑定了一个obsertablelist。。。
import java.util.Date;

/**
 *
 * @author Bernardo
 */
class EntradaMercadoria {

    private int nDoc;
    private int tipoDoc;
    private String fornecedor;
    private double quantidade;
    private Date dataEmissao;

    public EntradaMercadoria() {
    }

    /**
     * @return the nDoc
     */
    public int getnDoc() {
        return nDoc;
    }

    /**
     * @param nDoc the nDoc to set
     */
    public void setnDoc(int nDoc) {
        this.nDoc = nDoc;
    }

    /**
     * @return the tipoDoc
     */
    public int getTipoDoc() {
        return tipoDoc;
    }

    /**
     * @param tipoDoc the tipoDoc to set
     */
    public void setTipoDoc(int tipoDoc) {
        this.tipoDoc = tipoDoc;
    }

    /**
     * @return the fornecedor
     */
    public String getFornecedor() {
        return fornecedor;
    }

    /**
     * @param fornecedor the fornecedor to set
     */
    public void setFornecedor(String fornecedor) {
        this.fornecedor = fornecedor;
    }

    /**
     * @return the quantidade
     */
    public double getQuantidade() {
        return quantidade;
    }

    /**
     * @param quantidade the quantidade to set
     */
    public void setQuantidade(double quantidade) {
        this.quantidade = quantidade;
    }

    /**
     * @return the dataEmissao
     */
    public Date getDataEmissao() {
        return dataEmissao;
    }

    /**
     * @param dataEmissao the dataEmissao to set
     */
    public void setDataEmissao(Date dataEmissao) {
        this.dataEmissao = dataEmissao;
    }
}