Example usage for javax.swing.table DefaultTableModel addRow

List of usage examples for javax.swing.table DefaultTableModel addRow

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel addRow.

Prototype

public void addRow(Object[] rowData) 

Source Link

Document

Adds a row to the end of the model.

Usage

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void buscaDistrito() {
        DefaultTableModel tcidade = (DefaultTableModel) jTtcidade.getModel();
        tcidade.setNumRows(0);//  w  ww .  j  av  a2 s .co m
        ldb = new DistritoDao().getDistrito();
        for (DistritoBeans db : ldb) {
            tcidade.addRow(new Object[] { db.getIddistrito(), db.getDistrito(), db.getMunicipio(), db.getUf(),
                    db.getPais() });
        }
    }

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void buscaDistrito(String filtro, String campo) {
        DefaultTableModel tcidade = (DefaultTableModel) jTtcidade.getModel();
        tcidade.setNumRows(0);//from  w  w w .j a  va2  s.  c om
        ldb = new DistritoDao().getDistrito(filtro, campo);
        for (DistritoBeans db : ldb) {
            tcidade.addRow(new Object[] { db.getIddistrito(), db.getDistrito(), db.getMunicipio(), db.getUf(),
                    db.getPais() });
        }
    }

From source file:br.com.atmatech.sac.view.ViewAtendimento.java

private void buscaCliente(String parametro, String ordenacao) {
    lpb = new PessoaDao().getPessoaAtivo(parametro, ordenacao);
    DefaultTableModel tabelacliente = (DefaultTableModel) jTtdcliente.getModel();
    tabelacliente.setNumRows(0);/*ww w  .  j  a  v  a  2s  .com*/
    for (PessoaBeans pb : lpb) {
        tabelacliente.addRow(new Object[] { pb.getFantasia(), pb.getRazao(), pb.getCnpj(), pb.getDistrito(),
                pb.getEndereco() });
    }
}

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void buscaAnexo() {
        DefaultTableModel tbanexo = (DefaultTableModel) jTtanexo.getModel();
        tbanexo.setNumRows(0);//from  w  ww  . j a va2  s .  c  o m
        lab = new AnexoDao().getAnexo(Integer.valueOf(jTidpessoa.getText()));
        for (AnexoBeans ab : lab) {
            tbanexo.addRow(new Object[] { ab.getIdanexo(), false, ab.getDescricao(), ab.getData() });
        }
    }

From source file:br.com.atmatech.sac.view.ViewAtendimento.java

private void showJDtecnico() {
    lub = new UsuarioDao().getUsuario("tecnico", "true", "idusuario");
    DefaultTableModel tabelatecnico = (DefaultTableModel) jTtdtecnico.getModel();
    tabelatecnico.setNumRows(0);//from   ww w . j a  v a  2 s . c o m
    for (UsuarioBeans ub : lub) {
        tabelatecnico.addRow(new Object[] { ub.getNome() });
    }
    jDtecnico.setLocationRelativeTo(this);
    jDtecnico.setVisible(true);
}

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void buscaPessoa(String coluna, String parametro) {
        DefaultTableModel tabelapessoa = (DefaultTableModel) jTtempresa.getModel();
        tabelapessoa.setNumRows(0);/*from  w w  w .j av a 2s .  c o m*/
        lpb = new PessoaDao().getPessoa(coluna, parametro, coluna);
        for (PessoaBeans pb : lpb) {
            tabelapessoa.addRow(new Object[] { pb.getIdpessoa(), pb.getRazao(), pb.getFantasia(), pb.getCnpj(),
                    pb.getEndereco() });
        }
        if (tabelapessoa.getRowCount() == 0) {
            tabelapessoa.addRow(new Object[] {});
        }
    }

From source file:br.com.atmatech.sac.view.ViewPessoa.java

private void buscaPessoa() {
        DefaultTableModel tabelapessoa = (DefaultTableModel) jTtempresa.getModel();
        tabelapessoa.setNumRows(0);/* w  w  w  .j av a 2 s  .  c o  m*/
        try {
            lpb = new PessoaDao().getPessoa();
            for (PessoaBeans pb : lpb) {
                tabelapessoa.addRow(new Object[] { pb.getIdpessoa(), pb.getRazao(), pb.getFantasia(), pb.getCnpj(),
                        pb.getEndereco() });
            }
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao Consultar Clientes\n" + ex);
        }

    }

From source file:UserInterface.FinanceRole.OverallTransactionJPanel.java

private void populateTransactionTable() {

    DefaultTableModel dtm = (DefaultTableModel) transactionJTable.getModel();
    dtm.setRowCount(0);//from  w ww . j a v a2 s.  c  om

    if ((objOrganization instanceof WorldAdminOrganization)
            || (objOrganization instanceof FinanceOrganization)) {

        objWorldEnterprise.getObjTransactionDirectory().updateTransactionAccount();
        virBalJTextField.setText(
                "$ " + objWorldEnterprise.getObjTransactionDirectory().getAvailableVirtualBalance().toString());
        virSpentJTextField1.setText(
                "$ " + objWorldEnterprise.getObjTransactionDirectory().getTotalVirtualDebitAmount().toString());
        realBalJTextField.setText(
                "$ " + objWorldEnterprise.getObjTransactionDirectory().getAvailableRealBalance().toString());
        realSpentJTextField.setText(
                "$ " + objWorldEnterprise.getObjTransactionDirectory().getTotalRealDebitAmount().toString());

        for (Transaction objTransaction : objWorldEnterprise.getObjTransactionDirectory()
                .getTransactionList()) {

            Object row[] = new Object[9];
            row[0] = objTransaction;
            row[1] = objTransaction.getTransactionSource();
            row[2] = (objTransaction.getObjUserAccountSource() == null) ? ("N/A")
                    : (objTransaction.getObjUserAccountSource().getObjPerson());
            row[3] = objTransaction.getTransactionDestination();
            row[4] = (objTransaction.getObjUserAccountDestination() == null) ? ("N/A")
                    : (objTransaction.getObjUserAccountDestination().getObjPerson());
            row[5] = objTransaction.getTransactionType();
            row[6] = objTransaction.getTransactionMode();
            row[7] = "$ " + String.valueOf(objTransaction.getTransactionBDAmount());
            row[8] = objTransaction.getTransactionDateToDisplay();

            dtm.addRow(row);
        }
    }

    if (objOrganization instanceof RegisteredSiteAdminOrganization) {

        objRegisteredSiteEnterprise.getObjTransactionDirectory().updateTransactionAccount();
        virBalJTextField.setText("$ " + objRegisteredSiteEnterprise.getObjTransactionDirectory()
                .getAvailableVirtualBalance().toString());
        virSpentJTextField1.setText("$ " + objRegisteredSiteEnterprise.getObjTransactionDirectory()
                .getTotalVirtualDebitAmount().toString());
        realBalJTextField.setText("$ " + objRegisteredSiteEnterprise.getObjTransactionDirectory()
                .getAvailableRealBalance().toString());
        realSpentJTextField.setText("$ " + objRegisteredSiteEnterprise.getObjTransactionDirectory()
                .getTotalRealDebitAmount().toString());

        for (Transaction objTransaction : objRegisteredSiteEnterprise.getObjTransactionDirectory()
                .getTransactionList()) {

            Object row[] = new Object[9];
            row[0] = objTransaction;
            row[1] = objTransaction.getTransactionSource();
            row[2] = (objTransaction.getObjUserAccountSource() == null) ? ("N/A")
                    : (objTransaction.getObjUserAccountSource().getObjPerson());
            row[3] = objTransaction.getTransactionDestination();
            row[4] = (objTransaction.getObjUserAccountDestination() == null) ? ("N/A")
                    : (objTransaction.getObjUserAccountDestination().getObjPerson());
            row[5] = objTransaction.getTransactionType();
            row[6] = objTransaction.getTransactionMode();
            row[7] = "$ " + String.valueOf(objTransaction.getTransactionBDAmount());
            row[8] = objTransaction.getTransactionDateToDisplay();

            dtm.addRow(row);
        }
    }
}

From source file:grupob.TipoProceso.java

private void agregarDatosDistritos() {
    DefaultTableModel modelo = (DefaultTableModel) jTableDistritos.getModel();
    modelo.setRowCount(0);//from   w  w w . j  a v a 2s. c  om
    String datos[] = new String[4];
    for (int i = 0; i < listaDistritos.size(); i++) {
        datos[0] = listaDistritos.get(i).getNombre();
        if (listaDistritos.get(i).getCantidadVotantesRegistrados() == 0) {
            datos[1] = "";
        } else {
            datos[1] = Long.toString(listaDistritos.get(i).getCantidadVotantesRegistrados());
        }
        String n = Manager.queryByIdRegion(listaDistritos.get(i).getIdRegion()).getNombre();
        datos[2] = "" + n;
        modelo.addRow(datos);
    }
    TableColumn colum1 = null;
    colum1 = jTableDistritos.getColumnModel().getColumn(0);
    colum1.setPreferredWidth(60);
    TableColumn colum2 = null;
    colum2 = jTableDistritos.getColumnModel().getColumn(1);
    colum2.setPreferredWidth(5);
    TableColumn colum3 = null;
    colum3 = jTableDistritos.getColumnModel().getColumn(2);
    colum3.setPreferredWidth(5);
    TableColumn colum4 = null;
    colum4 = jTableDistritos.getColumnModel().getColumn(3);
    colum4.setPreferredWidth(40);
    colum4.setPreferredWidth(10);
}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

private void updateSoilInfoAndSoilLayerInfo(int index) {

    // Update the data in the table base on the index 0
    SoilData soilData = utils.getSoilData();
    String key = (String) soilFileListCombo.getItemAt(index);
    if (key == null) {
        return;/*  www . ja va2  s .co  m*/
    }

    soilNameCombo.removeAllItems();

    ArrayList<Soil> soilList = soilData.getSoilsFromFile(key);
    if (soilList.size() > 0) {

        for (Soil soil : soilList) {
            soilNameCombo.addItem(soil.getName());
        }

        DefaultTableModel model = (DefaultTableModel) soilTable.getModel();
        int row = model.getRowCount();
        for (int i = 0; i < row; i++) {
            model.removeRow(0);

        }

        int soilIndex = soilNameCombo.getSelectedIndex();
        Soil soil = soilList.get(soilIndex == -1 ? 0 : soilIndex);
        DU = soil.getDU();
        WCL = soil.getWCL();
        WCU = soil.getWCU();
        WC = soil.getWC();
        NL = soil.getNL();
        SNAME = soil.getName();
        utils.setDefaultSoil(soil);

        for (int i = 0; i < soil.getNL(); i++) {
            Object[] vec = new Object[4];
            vec[0] = i + 1;
            vec[1] = soil.getDU()[i];
            vec[2] = soil.getWC()[i];
            DecimalFormat df = new DecimalFormat("####0.000");
            vec[3] = df.format(WCU[i] - WCL[i]);
            model.addRow(vec);
        }
    }
}