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:com.mirth.connect.connectors.file.AdvancedSftpSettingsDialog.java

public void setFileSchemeProperties(SftpSchemeProperties schemeProperties) {
    if (schemeProperties.isPasswordAuth() && schemeProperties.isKeyAuth()) {
        useBothRadio.setSelected(true);//from w  w  w.  j  a  v a 2 s.c o m
    } else {
        if (schemeProperties.isKeyAuth()) {
            usePrivateKeyRadio.setSelected(true);
        } else {
            usePasswordRadio.setSelected(true);
        }
    }

    keyLocationField.setText(schemeProperties.getKeyFile());
    passphraseField.setText(schemeProperties.getPassPhrase());

    String hostnameVerification = schemeProperties.getHostChecking();
    if (hostnameVerification.equals("yes")) {
        useKnownHostsYesRadio.setSelected(true);
    } else if (hostnameVerification.equals("ask")) {
        useKnownHostsAskRadio.setSelected(true);
    } else {
        useKnownHostsNoRadio.setSelected(true);
    }

    knownHostsField.setText(schemeProperties.getKnownHostsFile());

    Map<String, String> configurationSettings = schemeProperties.getConfigurationSettings();
    if (configurationSettings != null && configurationSettings.size() > 0) {
        DefaultTableModel model = (DefaultTableModel) configurationsTable.getModel();
        model.setNumRows(0);

        for (Map.Entry<String, String> entry : configurationSettings.entrySet()) {
            model.addRow(new Object[] { entry.getKey(), entry.getValue() });
        }

        deleteButton.setEnabled(true);
    } else {
        configurationsTable.setModel(new RefreshTableModel(new Object[0][1], new String[] { "Name", "Value" }));
        configurationsTable.getColumnModel()
                .getColumn(configurationsTable.getColumnModel().getColumnIndex(NAME_COLUMN_NAME))
                .setCellEditor(new ConfigTableCellEditor(true));
        configurationsTable.getColumnModel()
                .getColumn(configurationsTable.getColumnModel().getColumnIndex(VALUE_COLUMN_NAME))
                .setCellEditor(new ConfigTableCellEditor(false));
    }

    authenticationRadioButtonActionPerformed();
}

From source file:UserInterface.FarmerRole.MyDashboardFarmer.java

public void populateLowQuantityTable() {
    DefaultTableModel dtm = (DefaultTableModel) lowQuantityTable.getModel();
    dtm.setRowCount(0);/*from w  w w  . j  av a2 s  .  c  o m*/
    for (InventoryItem item : userAccount.getInventory().getInventoryList()) {
        if (item.getQuantity() < item.getThreshold()) {
            Object row[] = new Object[3];
            row[0] = item;
            row[1] = item.getThreshold();
            row[2] = item.getQuantity();
            dtm.addRow(row);
        }
    }
}

From source file:userInterface.ManufacturerRole.ViewInventoryJPanel.java

private void populateTable() {
    DefaultTableModel dtm = (DefaultTableModel) VaacineJTable.getModel();
    dtm.setRowCount(0);/*from w  ww  .  j  av a 2  s. c o m*/
    for (Batch b : enterprise.getInventory().getBatchList()) {
        Object[] row = new Object[7];
        row[0] = b.getBatchNumber();
        row[1] = b.getVaccine().getCode();
        row[2] = b.getVaccine().getName();
        row[3] = b.getVaccine().getQuantity();
        row[4] = b.getVaccine().getStock();
        row[5] = b.getVaccine().getPrice() * b.getVaccine().getQuantity();
        row[6] = b.getVaccine().getFixedQty();
        dtm.addRow(row);
        totalInventory = b.getVaccine().getQuantity() + totalInventory;
        enterprise.getInventory().setTotalQuantity(totalInventory);

    }

}

From source file:userinterface.MetalRecyclingServiceRole.MetalRecyclingServiceJPanel.java

public void populateRequestTable() {
    DefaultTableModel model = (DefaultTableModel) jMetalRecycling.getModel();

    model.setRowCount(0);/*from ww  w  .  j a v a 2s .c  o  m*/
    for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) {
        Object[] row = new Object[3];
        row[0] = request;

        row[2] = ((MetalRecyclingWorkRequest) request).getSegregatedMetal();

        row[1] = ((MetalRecyclingWorkRequest) request).getReceiver();

        model.addRow(row);
    }
}

From source file:userinterface.AdministratorWorkArea.PopularDoctorJPanel.java

public void populateTable() {

    int max1 = Integer.MIN_VALUE;
    int max2 = Integer.MIN_VALUE;
    int max3 = Integer.MIN_VALUE;

    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof DoctorOrganization) {
            docOrg = organization;/*  w w w  . j  av a2 s  .c  o  m*/
            break;
        }
    }
    if (docOrg != null) {

        for (Employee doctor : docOrg.getEmployeeDirectory().getEmployeeList()) {
            if (doctor.getPatientCount() > max1) {
                max3 = max2;
                max2 = max1;
                max1 = doctor.getPatientCount();

                doc3 = doc2;
                doc2 = doc1;
                doc1 = doctor;
            } else if (doctor.getPatientCount() > max2 && doctor.getPatientCount() <= max1) {
                max3 = max2;
                max2 = doctor.getPatientCount();
                doc3 = doc2;
                doc2 = doctor;
            } else if (doctor.getPatientCount() <= max2 && doctor.getPatientCount() > max3) {
                max3 = doctor.getPatientCount();
                doc3 = doctor;
            }

        }

        if (doc3 != null && doc2 != null && doc1 != null) {
            topDocList.add(doc1);
            topDocList.add(doc2);
            topDocList.add(doc3);
        } else if (doc2 != null && doc1 != null) {
            topDocList.add(doc1);
            topDocList.add(doc2);
        } else if (doc1 != null) {
            topDocList.add(doc1);
        }

        //         topDocList.add(doc1);
        //         topDocList.add(doc2);
        //         topDocList.add(doc3);
    }

    DefaultTableModel dtm = (DefaultTableModel) doctorTable.getModel();

    int rowcount = doctorTable.getRowCount();

    for (int i = rowcount - 1; i >= 0; i--) {
        dtm.removeRow(i);
    }

    if (topDocList != null) {
        for (Employee doctor : topDocList) {

            Object row[] = new Object[2];
            row[0] = doctor == null ? "No Doctors in the Organization" : doctor;

            row[1] = doctor == null ? " " : doctor.getPatientCount();
            dtm.addRow(row);
        }

    } else {
        return;
    }

}

From source file:userinterface.PlasticRecyclingServiceRole.PlasticRecyclingJPanel.java

public void populateRequestTable() {
    DefaultTableModel model = (DefaultTableModel) jPlasticRecycling.getModel();

    model.setRowCount(0);//  w  w w .  ja v  a 2  s  . c o  m
    for (WorkRequest request : userAccount.getWorkQueue().getWorkRequestList()) {
        Object[] row = new Object[3];
        row[0] = request;

        row[2] = ((PlasticRecyclingWorkRequest) request).getSegregatedPlastic();

        row[1] = ((PlasticRecyclingWorkRequest) request).getReceiver();

        model.addRow(row);
    }
}

From source file:userInterface.CustomerWorkArea.ViewSensorHistoryJPanel.java

public void populateTable() {
    DefaultTableModel model = (DefaultTableModel) sensorJTable.getModel();
    model.setRowCount(0);//w  w  w.ja v  a 2  s  .c o m
    for (CarInspection carInspection : userAccount.getPerson().getCarInspectionHistory()
            .getCarInspectionHistory()) {
        Object[] row = new Object[7];
        row[0] = carInspection.getTimestamp();
        row[1] = carInspection.getAlignment();
        row[2] = carInspection.getBattery();
        row[3] = carInspection.getBrakingSys();
        row[4] = carInspection.getOilCheck();
        row[5] = carInspection.getPollutionLevel();
        row[6] = carInspection.getTyrePressure();
        model.addRow(row);
    }
}

From source file:dylemator.UserResultList.java

private void codeTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_codeTableMouseClicked
    int row = this.codeTable.getSelectedRow();
    DefaultTableModel infoModel = (DefaultTableModel) this.infoTable.getModel();
    DefaultTableModel resultsModel = (DefaultTableModel) this.resultsTable.getModel();
    String[] headers = exportData.get(0);
    String[] values = exportData.get(row + 1);
    infoModel.setRowCount(0);//from  w  ww .j av a 2  s .c o m
    resultsModel.setRowCount(0);

    for (int i = 0; i < 15; i++) {
        infoModel.addRow(new String[] { headers[i], values[i] });
    }
    for (int i = 15; i < headers.length; i++) {
        resultsModel.addRow(new String[] { headers[i], values[i] });
    }

}

From source file:gtu._work.ui.SvnLastestCommitInfoUI.java

void addRow(SvnFile svnFile, DefaultTableModel model) {
    model.addRow(new Object[] { //
            svnFile.fileName, //
            svnFile.author, //
            svnFile.lastestVersion, //
            DateFormatUtils.format(svnFile.file.lastModified(), "yyyy/MM/dd HH:mm:ss"), //
            svnFile.file.length() / 1024 + "k", //
            svnFile //
    });/*from   w  w w.  ja v a2 s. co  m*/
}

From source file:view.ResultsPanel.java

public void setTable(int nbMode, List<ElementaryMode> modes) {

    ElementaryMode mode = modes.get(nbMode);

    DefaultTableModel model = (DefaultTableModel) modeTable.getModel();

    while (model.getRowCount() > 0) {
        model.removeRow(0);/*from www . ja  v a 2  s. c o m*/
    }

    Map<Reaction, Double> map = mode.getContent();
    for (Reaction key : map.keySet()) {

        model.addRow(new Object[] { map.get(key), key.getName(), key.getStringReaction() });

    }

    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(modeTable.getModel());
    modeTable.setRowSorter(sorter);
    modeTable.getTableHeader().setReorderingAllowed(false);

    searchField.getDocument().addDocumentListener(new MyDocumentListener(searchField, sorter, 1, 2));

    searchField.setText(searchField.getText());

}