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:StoreAdmin.ManageStoreJPanel.java

private void btnviewinventoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnviewinventoryActionPerformed
    String s = txtStoreName.getText().trim();
    DefaultTableModel dtm = (DefaultTableModel) tblsearchedproduct.getModel();
    dtm.setRowCount(0);
    if (s != null) {

        refreshOrderTable();/*from   w  ww . j a  v a  2 s.  c  om*/
    } else {
        JOptionPane.showMessageDialog(this, "No store created", "Warning", JOptionPane.WARNING_MESSAGE);
        return;
    }
}

From source file:StoreAdmin.ManageStoreJPanel.java

private void populateProductTable() {
    DefaultTableModel dtm = (DefaultTableModel) tblProductDetails.getModel();

    dtm.setRowCount(0);

    for (Product product : pc.getProductList()) {
        Object row[] = new Object[5];
        row[0] = product;/*from w w w. ja va  2s.c  om*/
        row[1] = product.getProductName();
        row[2] = product.getManufacturer();
        row[3] = product.getAvailability();
        row[4] = product.getMarkedPrice();
        dtm.addRow(row);
    }

}

From source file:StoreAdmin.ManageStoreJPanel.java

private void btnsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsearchActionPerformed
    //         Store s= (Store)cmbstorelist.getSelectedItem();
    String key = txtsearch.getText();
    Product result = s.getInventoryDirectory().searchProduct(key);
    if (result != null) {
        DefaultTableModel dtm = (DefaultTableModel) tblsearchedproduct.getModel();
        dtm.setRowCount(0);
        for (Product p : s.getInventoryDirectory().getInventoryList()) {
            Object row[] = new Object[4];
            row[0] = p;/* w w  w .ja  v a 2s.c  om*/
            row[1] = p.getProductName();
            row[2] = p.getAvailability();
            row[3] = p.getSellingPrice();

            dtm.addRow(row);
        }
    }

    else {
        JOptionPane.showMessageDialog(null, "Product doesnot exist", "Success", JOptionPane.PLAIN_MESSAGE);
        return;
    }
}

From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.BeanInspectorPanel.java

private void jButton2ActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed1

    DefaultTableModel dtm = (DefaultTableModel) getJTableFields().getModel();
    dtm.setRowCount(0);

}

From source file:stockit.Trader.java

private void searchClientBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchClientBtnActionPerformed
    // TODO add your handling code here:
    String selectedClient = listOfClients.getSelectedValue();
    System.out.println(selectedClient);
    try {//w  w  w .  ja  v  a 2 s  .  c om
        DBConnection dbcon = new DBConnection();
        dbcon.establishConnection();
        Statement stmt = dbcon.con.createStatement();
        ResultSet rs = stmt.executeQuery(
                "SELECT stock.stockID, company.Name, stock_sector.Sector, stock_daily_performance.Currency, stock_daily_performance.High, stock_daily_performance.Low, stock_daily_performance.Closing_Price, has_positions.Qty, (stock_daily_performance.Opening_Price - stock_daily_performance.Closing_Price) AS Today_Change, ((stock_daily_performance.Opening_Price - stock_daily_performance.Closing_Price) * has_positions.Qty) AS Profit\n"
                        + "FROM stock, stock_sector, stock_daily_performance, has_positions, account, company, client\n"
                        + "WHERE client.Name = '" + selectedClient + "'"
                        + "AND client.Client_SSN = account.Client_SSN AND account.Account_ID = has_positions.Account_ID AND stock_daily_performance.StockID = has_positions.Stock_ID AND stock.StockID = has_positions.Stock_ID AND stock_sector.StockID = has_positions.Stock_ID AND company.StockID = stock.StockID AND Date IN\n"
                        + "( Select * from \n" + "(\n" + "SELECT max(Date) \n"
                        + "FROM stock_daily_performance, stock\n"
                        + "where stock_daily_performance.StockID=stock.StockID\n" + "group by stock.StockID\n"
                        + "ORDER BY Date\n" + ") temp_table)");
        DefaultTableModel model = (DefaultTableModel) table.getModel();
        model.setRowCount(0);
        while (rs.next()) {
            System.out.println(
                    rs.getString("stockID") + "\t" + rs.getString("Name") + "\t" + rs.getString("Sector") + "\t"
                            + rs.getString("Currency") + "\t" + rs.getString("Closing_Price") + "\t"
                            + rs.getString("Qty") + rs.getString("Today_Change"));
            model.addRow(new Object[] { rs.getString("stockID"), rs.getString("Name"), rs.getString("Sector"),
                    rs.getString("Qty"), rs.getString("High"), rs.getString("Low"),
                    rs.getString("Closing_Price"), rs.getString("Today_Change"), rs.getString("Currency"),
                    rs.getString("Profit") });
        }
        dbcon.con.close();
    } catch (Exception ex) {
        Logger.getLogger(clientLogin.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ca.uviccscu.lp.server.main.MainFrame.java

public static void addFreeRow() {
    DefaultTableModel md = (DefaultTableModel) jTable1.getModel();
    md.setRowCount(jTable1.getRowCount() + 1);
}

From source file:UserInterface.FinanceRole.DonateToPoorPeopleJPanel.java

private void populatePoorPeopleTable(CountryEnterprise objCountryEnterprise) {

    DefaultTableModel dtm = (DefaultTableModel) poorPeopleJTable.getModel();
    dtm.setRowCount(0);

    for (Organization objPPOrganization : objCountryEnterprise.getObjOrganizationDirectory()
            .getOrganizationList()) {/*from w  ww . j  av  a 2s  .  c  om*/
        if (objPPOrganization instanceof PoorPeopleOrganization) {
            for (UserAccount objUserAccount : objPPOrganization.getObjUserAccountDirectory()
                    .getUserAccountList()) {
                if (objUserAccount.getUserAccountStatus().equals(UserAccount.StatusType.Acitve.getValue())) {
                    Person objPerson = objUserAccount.getObjPerson();
                    if (objPerson.getPersonStatus().equals(Person.PersonRegStatusType.Active.getValue())) {

                        Object row[] = new Object[4];
                        row[0] = objPerson.getPersonInternationalID();
                        row[1] = objPerson;
                        row[2] = objUserAccount;
                        row[3] = objPerson.getObjFamilyMemberDirectory().getFamilyMemberList().size();

                        dtm.addRow(row);
                    }
                }
            }
        }
    }
}

From source file:UserInterface.PoorPeopleRole.PoorPeopleWorkAreaJPanel.java

private void populateTransactionTable() {

    DefaultTableModel dtm = (DefaultTableModel) transactionJTable.getModel();
    dtm.setRowCount(0);

    for (Transaction objTransaction : objUserAccount.getObjPerson().getObjPoorPeopleTransactionDirectory()
            .getTransactionList()) {/*from  w w w.  jav a 2  s  .  com*/

        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:userInteface.Patient.ManageVitalSignsJPanel.java

private void populatePatientsTable(ArrayList<Person> personList) {
    DefaultTableModel model = (DefaultTableModel) viewPatientsJTable.getModel();
    model.setRowCount(0);
    if (personList.isEmpty()) {
        JOptionPane.showMessageDialog(this, "No Persons found. Please add Persons", "Error",
                JOptionPane.INFORMATION_MESSAGE);
        return;//from www  .j a  va  2s.co  m
    }
    for (Person person : personList) {
        Object[] row = new Object[3];
        row[0] = person;
        row[1] = person.getAge();
        if (person.getPatient() != null) {
            row[2] = person.getPatient().getPatientID();
        } else {
            row[2] = "Patient Not Created";
        }

        model.addRow(row);
    }
}

From source file:userInteface.Patient.ManageVitalSignsJPanel.java

private void populateVitalSignTable(Person person) {

    DefaultTableModel model = (DefaultTableModel) viewVitalSignsJTable.getModel();
    model.setRowCount(0);
    if (person != null) {
        int patientAge = person.getAge();
        ArrayList<VitalSign> vitalSignList = person.getPatient().getVitalSignHistory().getHistory();

        if (vitalSignList.isEmpty()) {
            JOptionPane.showMessageDialog(this, "No vital signs found. Please add vital signs", "Error",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }/*  w  w  w .j  ava2  s. com*/
        for (VitalSign vitalSign : vitalSignList) {
            Object[] row = new Object[2];
            row[0] = vitalSign;
            row[1] = VitalSignStatus(patientAge, vitalSign);
            model.addRow(row);
        }
    }
}