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:Interface.FoodDistributionWorkArea.FoodDistributionWorkArea.java

public void populateHistoryTable() {

    DefaultTableModel model = (DefaultTableModel) tblFoodDistributionHistory.getModel();
    model.setRowCount(0);
    for (WorkRequest request : organization.getWorkQueue().getWorkRequestList()) {
        if (request.getStatus().equalsIgnoreCase("Distributed")) {
            Object[] row = new Object[7];
            row[0] = ((FoodDistributionWorkRequest) request);
            row[1] = ((FoodDistributionWorkRequest) request).getFood().getFoodBarCode();
            row[2] = ((FoodDistributionWorkRequest) request).getFood().getQuantity();
            row[3] = ((FoodDistributionWorkRequest) request).getFood().getFoodExpiryDate();
            row[4] = ((FoodDistributionWorkRequest) request).getStatus();
            row[5] = ((FoodDistributionWorkRequest) request).getFood().getNumberOfBenificary();
            model.addRow(row);//w w w . j  a va  2 s  . c  om
        }

    }
}

From source file:king.flow.action.DefaultMsgSendAction.java

private void showOnComponent(Object metaNode, TLSResult result) {
    Component meta = (Component) metaNode;
    getLogger(CommunicationWorker.class.getName()).log(Level.INFO, "Display component[{0}] type : {1}",
            new Object[] { String.valueOf(meta.getId()), meta.getType().value() });
    JsonParser jsonParser;/*from w  w w  .  j a v a 2  s .com*/
    JsonArray arrays;
    switch (meta.getType()) {
    case TABLE:
        try {
            jsonParser = new JsonParser();
            arrays = jsonParser.parse(result.getOkMsg()).asArray();
            JTable table = getBlock(meta.getId(), JTable.class);
            DefaultTableModel model = (DefaultTableModel) table.getModel();
            model.setRowCount(0);
            for (Iterator it = arrays.iterator(); it.hasNext();) {
                JsonArray row = (JsonArray) it.next();
                Vector<String> rowData = new Vector<>();
                for (Object v : row) {
                    rowData.add(v.toString());
                }
                model.addRow(rowData);
            }
        } catch (Exception e) {
            getLogger(CommunicationWorker.class.getName()).log(Level.WARNING,
                    "Invalid array data [ {0} ] for TABLE component[{1}], \n exception is {2}",
                    new Object[] { result.getOkMsg(), String.valueOf(meta.getId()), e });
        }
        break;
    case ADVANCED_TABLE:
        try {
            jsonParser = new JsonParser();
            JsonObject jsonObj = jsonParser.parse(result.getOkMsg()).asObject();
            Integer total = jsonObj.getInt(ADVANCED_TABLE_TOTAL_PAGES);
            Integer page = jsonObj.getInt(ADVANCED_TABLE_CURRENT_PAGE);
            arrays = jsonObj.getArray(ADVANCED_TABLE_VALUE);
            getLogger(CommunicationWorker.class.getName()).log(Level.INFO,
                    "Dump JSON DATA for ADVANCED_TABLE: \n{0} \ntotal: {1} \npage: {2}",
                    new Object[] { jsonObj.toString(), total, page });
            JXMsgPanel advanceTable = getBlock(meta.getId(), JXMsgPanel.class);
            advanceTable.refreshTotalPages(total);
            advanceTable.refreshCurrentPage(page);
            advanceTable.refreshTable(arrays);
        } catch (Exception e) {
            getLogger(CommunicationWorker.class.getName()).log(Level.WARNING,
                    "Invalid complex data [ {0} ] for ADVANCED_TABLE component[{1}] \n exception is {2}",
                    new Object[] { result.getOkMsg(), String.valueOf(meta.getId()), e });
        }
        break;
    case LABEL:
        JLabel label = getBlock(meta.getId(), JLabel.class);
        if (result.getRetCode() == 0) {
            label.setText(StringEscapeUtils.unescapeHtml(result.getOkMsg()));
        } else {
            label.setText(StringEscapeUtils.unescapeHtml(result.getErrMsg()));
        }
        break;
    case TEXT_FIELD:
        JTextField textField = getBlock(meta.getId(), JTextField.class);
        if (result.getRetCode() == 0) {
            textField.setText(result.getOkMsg());
        } else {
            CommonUtil.showErrorMsg(textField.getTopLevelAncestor(), result.getErrMsg());
        }
        break;
    default:
        getLogger(CommunicationWorker.class.getName()).log(Level.WARNING,
                "Unsupported displayed component type : {0}", meta.getType());
    }
}

From source file:userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.java

public void populateHealthyFamily(Person person) {
    DefaultTableModel model = (DefaultTableModel) hFamilesTable.getModel();
    model.setRowCount(0);
    for (Person p : healthyFamily) {
        Object[] row = new Object[1];
        row[0] = p;//from  w ww .j ava  2 s . c o m
        model.addRow(row);
    }
}

From source file:userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.java

public void populateunHealthyFamily(Person person) {
    DefaultTableModel model = (DefaultTableModel) uhFamilesTable.getModel();
    model.setRowCount(0);
    for (Person p : unHealthyFamily) {
        Object[] row = new Object[1];
        row[0] = p;/*ww  w .  j  a v a  2  s.co m*/
        model.addRow(row);
    }
}

From source file:userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.java

public void populateEfficientFamily(Person person) {
    DefaultTableModel model = (DefaultTableModel) efFamilesTable.getModel();
    model.setRowCount(0);
    for (Person p : efficientHouse) {
        Object[] row = new Object[1];
        row[0] = p;/*  ww  w .j a  v a 2 s.c om*/
        model.addRow(row);
    }
}

From source file:userInterface.DistrictAdminRole.MonitorNeighborhoodAreasJPanel.java

public void populateUnEfficientFamily(Person person) {
    DefaultTableModel model = (DefaultTableModel) unefFamilesTable.getModel();
    model.setRowCount(0);
    for (Person p : unefficientHouse) {
        Object[] row = new Object[1];
        row[0] = p;// w  w w.  ja  v a2  s. c o m
        model.addRow(row);
    }
}

From source file:userinterface.CyberSecurity.CyberSecurityJPanel.java

private void populateEmployeeTable(List<UserAccount> userAccounts) {
    DefaultTableModel model = (DefaultTableModel) employeeTable.getModel();
    employeeTable.removeAll();//  w ww. ja v  a 2s  . c  o  m
    model.setRowCount(0);

    int serialNumber = 0;
    for (UserAccount userAccount : userAccounts) {
        LoginDetails latestLoginDetails = userAccount.getLatestLoginDetails();
        Employee employee = userAccount.getEmployee();
        List<Object> row = new ArrayList<>();
        row.add(++serialNumber);
        row.add(employee.getId());
        row.add(employee.getName());
        if (null != latestLoginDetails) {
            row.add(latestLoginDetails.getLoginDate() + " "
                    + LoginDetails.getFormattedTime(latestLoginDetails.getLoginTime()));
            row.add(latestLoginDetails.getLoginDate() + " "
                    + LoginDetails.getFormattedTime(latestLoginDetails.getLogoutTime()));
        } else {
            row.add("N/NA");
            row.add("N/A");
        }
        model.addRow(row.toArray());
    }
}

From source file:statisticsintegration.StatisticsLabr.java

private void ok2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok2ActionPerformed
    Integer size = 0;//from   w ww  . ja va  2 s  .c  o m
    System.out.println("Nisulod");
    try {
        size = Integer.parseInt(Size.getText());
    } catch (Exception e) {
        Warnings.setText("Invalid size");
    }
    Warnings1.setText("");
    if (Categorical.isSelected() == true && Numerical.isSelected() == false) {
        String header[] = { "Values", "Percentage" };
        DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
        dtm.setRowCount(size);
        dtm.setColumnCount(2);

        for (int i = 0; i < jTable1.getColumnCount(); i++) {
            TableColumn column1 = jTable1.getTableHeader().getColumnModel().getColumn(i);
            column1.setHeaderValue(header[i]);
        }
    } //GEN-LAST:event_ok2ActionPerformed
    else if (Numerical.isSelected() == true && Categorical.isSelected() == false) {
        String header[] = { "VAL", "CL", "True CL", "MP", "FQ", "%", "CF", "C%" };
        DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();
        dtm.setRowCount(size);
        dtm.setColumnCount(8);

        for (int i = 0; i < jTable1.getColumnCount(); i++) {
            TableColumn column1 = jTable1.getTableHeader().getColumnModel().getColumn(i);
            column1.setHeaderValue(header[i]);
        }
    } else {
        Warnings1.setText("Select one operation");
    }
}

From source file:userinterface.CyberSecurity.CyberSecurityJPanel.java

private void populateEmployeeInfo() {
    DefaultTableModel model = (DefaultTableModel) employeeTable.getModel();
    employeeTable.removeAll();//  w  w w .j ava2 s  . co  m
    model.setRowCount(0);

    Organization organization = (Organization) organizationComboBox.getSelectedItem();
    UserAccountDirectory userAccountDirectory = organization.getUserAccountDirectory();

    if (null == userAccountDirectory) {
        return;
    }

    int serialNumber = 0;
    for (UserAccount userAccount : userAccountDirectory.getUserAccountList()) {
        LoginDetails latestLoginDetails = userAccount.getLatestLoginDetails();
        Employee employee = userAccount.getEmployee();
        List<Object> row = new ArrayList<>();
        row.add(++serialNumber);
        row.add(employee.getId());
        row.add(employee.getName());
        if (null != latestLoginDetails) {
            row.add(latestLoginDetails.getLoginDate() + " "
                    + LoginDetails.getFormattedTime(latestLoginDetails.getLoginTime()));
            row.add(latestLoginDetails.getLoginDate() + " "
                    + LoginDetails.getFormattedTime(latestLoginDetails.getLogoutTime()));
        } else {
            row.add("N/A");
            row.add("N/A");
        }
        model.addRow(row.toArray());
    }
}

From source file:UserInterfaces.HAdministration.BloodReportJPanel.java

private void populateTbale() {

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

    for (WorkRequest w : enterprise.getWorkQueue().getWorkRequestList()) {
        if (w.getLevel2().equals(ErrorUtil.BLOOD_OR_BLOOD_PRODUCT)) {
            Object[] row = new Object[4];
            row[0] = w.getDateoferror();
            row[1] = w.getBloodtyep();//  ww w .  j ava2 s. c  o  m
            row[2] = w.getBloodstage();
            row[3] = w.getSource();

            model.addRow(row);

        }
    }

}