Example usage for javax.swing.table DefaultTableModel setRowCount

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

Introduction

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

Prototype

public void setRowCount(int rowCount) 

Source Link

Document

Sets the number of rows in the model.

Usage

From source file:UserInterface.DoctorAdmin.TakeRequestJPanel.java

public void populateTable() {

    DefaultTableModel model = (DefaultTableModel) tblDocWorkRequest.getModel();
    model.setRowCount(0);
    for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) {
        if (organization instanceof DoctorAdminOrganization) {
            pdwrequest = (PatientDoctorWorkRequest) request;
            if (!pdwrequest.getStatus().equals("Task completed")) {
                Object[] row = new Object[4];

                row[0] = pdwrequest;/*w w  w  . ja v  a2s . c om*/
                row[1] = pdwrequest.getSender().getUserName();
                row[2] = pdwrequest.getReceiver() == null ? "Not assigned"
                        : request.getReceiver().getEmployee().getFirstName();
                row[3] = pdwrequest.getStatus();
                model.addRow(row);
            }
        }
    }
}

From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java

public void populateTable() {
    DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
    dtm.setRowCount(0);
    for (Sensor sensor : userAccount.getCustomer().getSensorDirectory().getSensorDirectory()) {
        Object[] row = new Object[9];
        row[0] = sensor;/* w w w .j a v  a  2s .co m*/
        row[1] = sensor.getCurrentEmissionCO2();
        row[2] = sensor.getNormalCO2();
        row[3] = sensor.getCurrentEmissionNOx();
        row[4] = sensor.getNormalNOx();
        row[5] = sensor.getSolarCurrentEmissionCO2();
        row[6] = sensor.getSolarNormalCO2();
        row[7] = sensor.getSolarCurrentEmissionNOx();
        row[8] = sensor.getSolarNormalNOx();

        dtm.addRow(row);
    }
}

From source file:edu.harvard.i2b2.patientMapping.ui.AdminToolJPanel.java

private void jAuditButtonActionPerformed(java.awt.event.ActionEvent evt) {
    String userID = jUserIdTextField.getText();//UserInfoBean.getInstance().getUserName();
    String patientID = jPatientIdTextField.getText();
    String site = jSiteNameTextField.getText();
    String projectID = (String) jProjectIdComboBox.getSelectedItem();
    //UserInfoBean.getInstance().getProjectId();

    String result = IMQueryClient.getAudit(userID, patientID, projectID, site);

    PDOResponseMessageModel pdoresponsefactory = new PDOResponseMessageModel();

    //PDOResponseMessageModel pdoresponsefactory = new PDOResponseMessageModel();
    try {/*from   w  w w  .j a  v a 2s.  com*/
        StatusType status = pdoresponsefactory.getStatusFromResponseXML(result);
        if (!status.getType().equalsIgnoreCase("DONE")) {
            final String info = status.getValue();
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    //setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    JOptionPane.showMessageDialog(jLabel2, info + ".");
                }
            });
            return;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    try {
        List<AuditType> factSets = pdoresponsefactory.getAuditsFromResponseXML(result);
        if (factSets != null) {
            log.info("Total audits: " + factSets.size());
            jTable1.removeAll();
            DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
            model.setRowCount(factSets.size());

            for (int i = 0; i < factSets.size(); i++) {
                AuditType audit = factSets.get(i);
                jTable1.setValueAt(audit.getProjectId(), i, 0);
                jTable1.setValueAt(audit.getUserId(), i, 1);
                jTable1.setValueAt(audit.getPid(), i, 2);
                jTable1.setValueAt(audit.getSource(), i, 3);
                jTable1.setValueAt(audit.getImportDate(), i, 4);
                jTable1.setValueAt(audit.getComment(), i, 5);
            }
            // for(int i=0;
            // i<patientDimensionSet.getPatientDimension().size();i++) {
            // PatientDimensionType patientType =
            // patientDimensionSet.getPatientDimension().get(i);
            // System.out.println("PatientNum: " +
            // patientType.getPatientNum());
            // }
        } else {
            //return "error";
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // / testing the visit set
    // PatientDataType.VisitDimensionSet visitSet =
    // pdoresponsefactory.getVisitSetFromResponseXML(result);
    // System.out.println("Total visits: "+visitSet.getVisitDimension().
    // size());
}

From source file:co.edu.eam.ingesoft.desarrollo.vista.gui.ReportesEstadisticas.java

/**
 * lista la tabla con todos los datos requeridos
 *///from  w  ww  .j  av a  2s  .  c om
public void listarTabla(Empresa e) {
    try {
        DefaultTableModel dtm = (DefaultTableModel) jTtablaEmpresaEgresado.getModel();
        dtm.setRowCount(0);
        List<InformacionLaboral> lista = controlador.listarEgresadosPorEmpresa(e);

        for (InformacionLaboral infoLaboral : lista) {
            dtm.addRow(new Object[] { infoLaboral.getEgresado().getNombre(),
                    infoLaboral.getEgresado().getPrograma(), infoLaboral.getCargo(),
                    infoLaboral.getFechaIngreso() });
        }

    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}

From source file:UserInterface.AuthorityWorkArea.DrugAnalysisJPanel.java

private void populateMedicineApprovalTable() {
    DefaultTableModel model = (DefaultTableModel) medicineAreajTable.getModel();
    model.setRowCount(0);

    Authority authority = ecosystem.getAuthority();
    for (WorkRequest wr : authority.getWorkQueue().getWorkRequestList()) {

        DrugApprovalRequest dar = (DrugApprovalRequest) wr;
        if (dar instanceof WorkRequest) {
            for (Drug drug : dar.getDrugDirectory().getDrugList()) {
                Object[] row = new Object[10];
                row[0] = dar.getReqId();
                row[1] = drug.getDrugName();
                row[2] = drug;/* w ww  .  j  a  v  a 2  s  . c  om*/
                row[3] = drug.getDisease().getDiseaseName();
                row[4] = dar.getSender() == null ? ("N/A") : dar.getSender().getPerson().getName();
                row[5] = dar.getReceiver() == null ? ("N/A") : dar.getReceiver().getPerson().getName();
                row[6] = dar;
                row[7] = dar.getMessage() == null ? ("Evaluation Required") : wr.getMessage();
                row[8] = dar.getCompanyName();
                row[9] = dar.getCompanyId();

                model.addRow(row);
            }
        }
    }
}

From source file:charitypledge.Pledge.java

public void tableRefresh() {
    DefaultTableModel model = (DefaultTableModel) PledgeViewTable.getModel();
    model.setRowCount(0);
    JsonImport();
}

From source file:userInterface.SystemAdmin.PovertyAnalysisJPanel.java

/**
 * Creates new form PoveryAnalysisJPanel
 *//*from  w  w  w. jav a2 s  .c om*/
public PovertyAnalysisJPanel(JPanel userProcessContianer, EcoSystem business) {
    initComponents();
    this.ecoSystem = business;
    this.userProcessContainer = userProcessContianer;
    this.crimeDataset = new DefaultCategoryDataset();
    this.pireChartDataset = new DefaultPieDataset();

    int averageIncome = 0, num = 0, crminals = 0, crimeRate = 0, sumIncome = 0;
    int numBelowPoverty = 0;
    int doesHaveLicesnse = 0;
    int doesHaveLicesnsePercent = 0;
    DefaultTableModel model = (DefaultTableModel) povertyJTable.getModel();
    model.setRowCount(0);
    for (String networkKeys : business.getNetworkList().keySet()) {
        Network newNetwork = business.getNetworkList().get(networkKeys);
        crimeRate = 0;
        crminals = 0;
        num = 0;
        averageIncome = 0;
        sumIncome = 0;
        numBelowPoverty = 0;
        doesHaveLicesnse = 0;
        doesHaveLicesnsePercent = 0;
        personDirectory = newNetwork.getPersonDirectory();
        crimeRecords = newNetwork.getCrimeRecords();
        //JOptionPane.showMessageDialog(this, newNetwork);

        for (String personKeys : personDirectory.getPersonList().keySet()) {
            Person person = personDirectory.getPersonList().get(personKeys);
            if (person.getMonthlyIncome() > 0) {
                sumIncome = sumIncome + person.getMonthlyIncome();
                num++;
            }

        }
        averageIncome = sumIncome / num;
        //JOptionPane.showMessageDialog(povertyJTable, "Average Income for Netowrk "+ newNetwork.getName()+" is"+averageIncome);

        for (String personKeys : personDirectory.getPersonList().keySet()) {
            Person person = personDirectory.getPersonList().get(personKeys);
            if (person.getMonthlyIncome() > 0) {
                if (person.getMonthlyIncome() < averageIncome) {
                    //JOptionPane.showMessageDialog(povertyJTable, person.getFirstName() + " "+ person.getMonthlyIncome());
                    numBelowPoverty++;
                }
                if (person.getDoesHaveLicense() == 1) {
                    doesHaveLicesnse++;
                }

            }
            if (newNetwork.getCrimeRecords().searchPersonRecord(person.getSSN()) != null) {
                crminals++;
            }

        }
        //num++;
        //numBelowPoverty++;
        int poverty = (100 * numBelowPoverty) / num;
        crimeRate = (100 * crminals) / num;
        doesHaveLicesnsePercent = (100 * doesHaveLicesnse) / num;
        Object[] row = new Object[7];
        row[0] = newNetwork;
        row[1] = num;
        row[2] = averageIncome;
        row[3] = doesHaveLicesnsePercent;
        row[4] = poverty;
        row[5] = crimeRecords.getCrimeRecord().values().size();
        row[6] = crimeRate;
        model.addRow(row);

        crimeDataset.addValue(crimeRate, "Crime Rate", newNetwork.getName() + " Crime Rate");
        crimeDataset.addValue(poverty, "Poverty Rate", newNetwork.getName() + " Poverty Rate");
        crimeDataset.addValue(doesHaveLicesnsePercent, "People Having FireArms License",
                newNetwork.getName() + " FireArms Holders");
        pireChartDataset.setValue(newNetwork.getName(), crimeRecords.getCrimeRecord().values().size());
    }

}

From source file:dylemator.UserResultList.java

private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
    int row = this.codeTable.getSelectedRow();
    if (row == -1)
        return;/*from   www  .  j ava2 s .c o  m*/
    String[] values = exportData.get(row + 1);
    int dialogResult = JOptionPane.showConfirmDialog(null, "Usun wyniki uytkownika " + values[0] + "?",
            "Warning", JOptionPane.YES_NO_OPTION);
    if (dialogResult == JOptionPane.YES_OPTION) {
        exportData.remove(row + 1);
        DefaultTableModel m = (DefaultTableModel) codeTable.getModel();
        m.setRowCount(0);
        for (int i = 1; i < exportData.size(); i++) {
            m.addRow(new String[] { exportData.get(i)[0] });
        }
        DefaultTableModel n = (DefaultTableModel) infoTable.getModel();
        DefaultTableModel o = (DefaultTableModel) resultsTable.getModel();
        n.setRowCount(0);
        o.setRowCount(0);
        try {
            OutputStreamWriter output = new FileWriter(this.selectedFilename);
            BufferedWriter bufferWriter = new BufferedWriter(output);
            for (String[] v : exportData) {
                String s = StringUtils.join(v, ";");
                bufferWriter.write(s + "\n");
            }
            bufferWriter.flush();
            bufferWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(UserResultList.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}

From source file:dk.i2m.netbeans.modules.ldapexplorer.ui.ExplorerTopComponent.java

/**
 * Event handler for when an {@link LdapEntryNode} is selected.
 *
 * @param ev Event that invoked the handler
 *//*from w ww  .j  a va 2  s . co  m*/
public void resultChanged(LookupEvent ev) {

    Collection c = result.allInstances();

    // Get the model of the attribute table
    DefaultTableModel model = (DefaultTableModel) tblAttributes.getModel();
    model.setRowCount(0);

    txtLdif.setText("");

    if (!c.isEmpty()) {
        LdapEntryNode e = (LdapEntryNode) c.iterator().next();

        try {
            // Get the LdapEntry associated with this node
            LdapEntry entry = e.getLookup().lookup(LdapEntry.class);

            // Show LdapEntry if it was found for this node
            // Note: On the root node there is no LdapEntry, hence the check
            if (entry != null) {
                entry = server.getEntry(entry.getDn());
                ldifPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1));
                txtLdif.setText(entry.toLDIF());

                // Add the DN as it is not part of the attributes
                addRow(model, "dn", entry.getDn());

                for (String att : entry.getAttributes().keySet()) {
                    for (Object val : entry.getAttributes().get(att)) {
                        addRow(model, att, val);
                    }
                }
            } else {
                txtLdif.setText("");
            }
        } catch (QueryException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }
    }
}

From source file:userinterface.InventoryRole.InventoryWorkAreaJPanel.java

public void populateTable() {
    DefaultTableModel model = (DefaultTableModel) inventoryTable.getModel();

    model.setRowCount(0);
    for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) {
        if (request instanceof DoctorWorkRequest) {
            //DoctorWorkRequest req= (DoctorWorkRequest) request;
            Object[] row = new Object[4];
            row[0] = request.getSender();
            row[1] = request.getBloodGroup();
            row[2] = ((DoctorWorkRequest) request);
            row[3] = request.getStatus();

            model.addRow(row);/*from   ww  w.jav a2s .co  m*/
        }

    }

}