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:megacasting.view.StatistiqueForm.java

/**
 * Charge les lignes du tableau type contrat
 * Nom du type de contrat X, Nb d'offres du type de contrat X, Nb de postes du type de contrat X
 *//*from  www .ja va  2 s. c o  m*/
private void refreshTableTypeContrat() {
    // On recupre le model
    DefaultTableModel model = (DefaultTableModel) tableTypeContrat.getModel();

    // Liste de tous les type de contrats
    ArrayList<TypeContrat> typeContrats = TypeContratDAO.lister(mainJFrame.cnx);

    // On vide les lignes 
    model.setRowCount(0);

    // Pour chaque type de contrat
    for (TypeContrat tc : typeContrats) {
        // Liste des offres du type de contrat
        ArrayList<Offre> offresFinal = OffreDAO.lister(mainJFrame.cnx, tc);

        // Initialisation du nb de postes  0
        int nbPostes = 0;

        // Pour chaque offre du type de contrat
        for (Offre of : offresFinal) {
            // On compte le nb de potes
            nbPostes += of.getNbPoste();
        }

        // On ajoute la ligne au model
        model.addRow(new Object[] {
                // Libelle du type de contrat
                tc.getLibelle(),
                // Nombre d'offres ayant ce type de contrat
                offresFinal.size(),
                // Nombre de postes ayant ce type de contrat
                nbPostes });
    }
}

From source file:UserInterfaces.HAdministration.FallReportJPanel.java

private void populateTable() {

    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
    model.setRowCount(0);

    for (WorkRequest w : enterprise.getWorkQueue().getWorkRequestList()) {
        if (w.getLevel2().equals(ErrorUtil.FALL)) {
            Object[] row = new Object[3];
            row[0] = w.getDateoferror();
            row[1] = w.getCauseoffall();
            row[2] = w.getSource();/*from   w  w w  . j av a 2  s .  c  o m*/
            model.addRow(row);

        }
    }
}

From source file:com.smanempat.view.ViewClassification.java

private void buttonReClassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReClassActionPerformed
    // TODO add your handling code here:
    txtNumberOfK.requestFocus();//  w  ww .j av  a  2  s .c  o m
    DefaultTableModel tabModeRes = (DefaultTableModel) tableResult.getModel();
    tabModeRes.setRowCount(0);
    buttonSimpan.setEnabled(false);
    buttonReClass.setEnabled(false);
    jPanel5.setVisible(false);
    jTabbedPane1.setSelectedIndex(0);
}

From source file:frames.MainGUI.java

private void addAllResidentInfoTable() {
    DefaultTableModel model = (DefaultTableModel) this.jTable1.getModel();
    model.setRowCount(0);
    for (Resident r : datatype.GlobalVariable.RESIDENTS) {
        this.addRowToResidentInfoTable(r);
    }//from  w ww. j  a  v  a2 s. co  m
}

From source file:userInterface.EnergySourceBoardSupervisor.ManageEnergyConsumptionsJPanel.java

public void populateAlertTable() {
    DefaultTableModel dtm = (DefaultTableModel) alertDetailsTable.getModel();
    dtm.setRowCount(0);

    for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) {
        if (userAccount.getWorkQueue().getWorkRequestList() != null) {
            Object[] row = new Object[7];

            row[0] = request.getMessage();
            row[1] = request.getReceiver();
            row[2] = request.getSender();
            row[3] = ((HighEnergyConsumptionWorkRequest) request).getComment();
            row[4] = request.getStatus();
            row[5] = request.getRequestDate();
            row[6] = ((HighEnergyConsumptionWorkRequest) request).getResponse();
            // row[1] = request.getStatus();

            dtm.addRow(row);/* w w  w . j a  v a2 s. c  om*/
        }
    }
}

From source file:frames.MainGUI.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
    for (int i = 0; i < datatype.GlobalVariable.RESIDENTS.size(); i++) {
        System.out.println(datatype.GlobalVariable.RESIDENTS.get(i).name);
        for (Fee f : datatype.GlobalVariable.RESIDENTS.get(i).extra_fee) {
            System.out.println(f.name);
        }//w ww .jav a 2  s  .  c o m
    }
    DefaultTableModel model = (DefaultTableModel) this.jTable3.getModel();
    model.setRowCount(0);
    for (Resident r : datatype.GlobalVariable.RESIDENTS) {
        model.addRow(new Object[] { r.name, String.valueOf(r.basic_rent),
                String.format("%.2f", this.computeAvgFee(r)),
                String.format("%.2f", this.computeAvgFee(r) + r.basic_rent),
                String.format("%.2f", this.computePaid(r)), String.format("%.2f", this.computeShouldPay(r)) });
    }

    this.writeReport();
}

From source file:megacasting.view.StatistiqueForm.java

/**
 * Charge les lignes du tableau domaine//from w ww  . ja  va2s  . c o  m
 * Nom du domaine X, Nb de mtiers du domaine X, Nb d'offres du domaine X, Nb de postes du domaine X
 */
private void refreshTableDomaine() {
    // On rcupre le model
    DefaultTableModel model = (DefaultTableModel) tableDomaine.getModel();

    // Liste de tous les domaines
    ArrayList<Domaine> domaines = DomaineDAO.lister(mainJFrame.cnx);

    ArrayList<Metier> metiers = new ArrayList<>();

    // Vide les lignes
    model.setRowCount(0);

    // Pour chaque domaine
    for (Domaine d : domaines) {
        // Liste des mtiers du domaine
        metiers = MetierDAO.lister(mainJFrame.cnx, d);

        // Liste des offres du domaine (celles qui n'ont pas de mtier)
        ArrayList<Offre> offresFinal = OffreDAO.lister(mainJFrame.cnx, d, null);

        // On initialise le nb de postes  0
        int nbPostes = 0;

        // Pour chaque mtier
        for (Metier m : metiers) {
            // Liste des offres du mtier (et donc du domaine)
            ArrayList<Offre> offresTemp = OffreDAO.lister(mainJFrame.cnx, m);
            // Pour chaque offre du mtier
            for (Offre o : offresTemp) {
                // On l'ajoute  la liste des offres du domaine
                offresFinal.add(o);
            }
        }

        // Pour chaque offre du domaine
        for (Offre of : offresFinal) {
            // On compte le nombre de postes
            nbPostes += of.getNbPoste();
        }

        // On ajoute la ligne dans le model
        model.addRow(new Object[] {
                // Libelle du domaine
                d.getLibelle(),
                // Nombre de mtiers dans ce domaine
                metiers.size(),
                // Nombre d'offres pour ce domaine
                offresFinal.size(),
                // Nombre de postes pour ce domaine
                nbPostes });
    }
}

From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java

private void populateDriverUseraccount() {

    DefaultTableModel model = (DefaultTableModel) tblDriverUserAccount.getModel();
    model.setRowCount(0);

    for (UserAccount ua : organization.getUserAccountDirectory().getUserAccountList()) {
        Object row[] = new Object[2];
        row[0] = ua;/*from   w  ww  . j a v  a  2 s .  c  o m*/
        row[1] = ua.getRole();
        model.addRow(row);
    }

}

From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java

private void populateNewRequestTable() {
    DefaultTableModel model = (DefaultTableModel) tblNewRequest.getModel();
    model.setRowCount(0);
    for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) {
        //request = (FoodCollectionWorkRequest) request;
        if (request.getStatus().equalsIgnoreCase("New Request")) {

            Object[] row = new Object[7];
            row[0] = ((FoodCollectionWorkRequest) request);
            row[1] = ((FoodCollectionWorkRequest) request).getFood().getFoodType();
            row[2] = ((FoodCollectionWorkRequest) request).getSender().getEmployee();
            row[3] = ((FoodCollectionWorkRequest) request).getFood().getFoodPriority();
            row[4] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getAddress();
            row[5] = ((FoodCollectionWorkRequest) request).getDriverName();
            row[6] = request.getStatus();
            model.addRow(row);/*from w  w w.  ja  v  a2s  . c om*/
        }

    }

}

From source file:Interface.FoodCollectionSupervisor.FoodCollectionWorkArea.java

private void populateAssignedRequestTable() {
    DefaultTableModel model = (DefaultTableModel) tblAssignedRequests.getModel();
    model.setRowCount(0);
    for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) {
        //request = (FoodCollectionWorkRequest) request;
        if (request.getStatus().equalsIgnoreCase("Pending for pickup")) {
            Object[] row = new Object[7];
            row[0] = ((FoodCollectionWorkRequest) request);
            row[1] = ((FoodCollectionWorkRequest) request).getFood().getFoodType();
            row[2] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getName();
            row[3] = ((FoodCollectionWorkRequest) request).getFood().getFoodPriority();
            row[4] = ((FoodCollectionWorkRequest) request).getSender().getEmployee().getAddress();
            row[5] = ((FoodCollectionWorkRequest) request).getDriverName();
            row[6] = request.getStatus();
            model.addRow(row);//  w w w. j a  va 2  s  .  com
        }

    }

}