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:aplicarFiltros.PanelResultado.java

public void actualizarDataSetCount() {
    Standar stan = new Standar(getClasificador());
    DefaultTableModel model = (DefaultTableModel) tableRasgos2.getModel();
    DecimalFormat formater = new DecimalFormat("0.00");
    DecimalFormat formaterInteger = new DecimalFormat("0");

    for (RubroCalidad agrupador : datasetPixelModel.keySet()) {
        Agrupador agrupadorClase = datasetPixelModel.get(agrupador);
        Double porcentaje = 0.0;/*from   www  . j  a v  a2  s  .  com*/
        if (totalPixeles != 0)
            porcentaje = (agrupadorClase.getArea() * 100f) / totalPixeles;
        agrupadorClase.setPorcentaje(porcentaje);
        model.addRow(new Object[] { agrupador.getDescripcion(),
                formaterInteger.format(agrupadorClase.getCantidad()), formater.format(porcentaje) + "%" });
        //datasetCountPorc.put(agrupador, porcentaje.floatValue());
        //Grafico
        datasetCount.setValue(agrupador.getDescripcion(), agrupadorClase.getArea());
    }

    int clasificadosIncorrectamente = getClasificador().getClasificadosIncorrectamente().size();
    int cantidadObjetos = getClasificador().countObject() - 1; // Cantidad de objetos menos el objeto referencia
    long clasificadosCorrectamente = cantidadObjetos - clasificadosIncorrectamente;
    Double porcentajeCorrectamente = 0.0;
    Double porcentajeIncorrectamente = 0.0;
    if (cantidadObjetos != 0) {
        porcentajeCorrectamente = (clasificadosCorrectamente * 100) / (double) cantidadObjetos;
        porcentajeIncorrectamente = (clasificadosIncorrectamente * 100) / (double) cantidadObjetos;
    }

    model.addRow(new Object[] { "Clasificados Correctamente", clasificadosCorrectamente,
            formater.format(porcentajeCorrectamente) + "%" });
    model.addRow(new Object[] { "Clasificados Incorrectamente", clasificadosIncorrectamente,
            formater.format(porcentajeIncorrectamente) + "%" });

    RubroCalidad humedad = getClasificador().getRubroCalidad(Clasificador.RUBRO_CALIDAD_HUMEDAD);
    RubroCalidad pesoHectolitrico = getClasificador()
            .getRubroCalidad(Clasificador.RUBRO_CALIDAD_PESO_HECTOLITRICO);
    datasetPixelModel.put(pesoHectolitrico,
            new Agrupador(pesoHectolitrico.getDescripcion(), 0.0, 0.0, this.pesoHectolitrico, false));
    datasetPixelModel.put(humedad, new Agrupador(humedad.getDescripcion(), 0.0, 0.0, this.humedad, false));

    Rebaja rebaja = stan.getNorma(datasetPixelModel);
    Norma norma = rebaja.getNorma();
    this.resultado.setText(norma.getName());
    this.Descuento.setText(rebaja.getDescuento() + "%");
}

From source file:UserInterface.DonorRole.DonorWorkAreaJPanel.java

private void populateDonationTable() {

    DefaultTableModel dtm = (DefaultTableModel) donationJTable.getModel();
    dtm.setRowCount(0);//from  w w  w . j  av a 2  s  .  c om

    for (Transaction objTransaction : objPerson.getObjDonorTransactionDirectory().getTransactionList()) {

        Object row[] = new Object[3];
        row[0] = objTransaction;
        row[1] = objTransaction.getTransactionDateToDisplay();
        row[2] = "$ " + String.valueOf(objTransaction.getTransactionBDAmount());
        dtm.addRow(row);
    }
}

From source file:co.edu.eam.dinesoft.egresados.vista.gui.VentanaReportes.java

private void refrescarTablaInfoLab(Empresa e) {
    try {/*www . j  av a  2  s  .  c  o  m*/
        DefaultTableModel dtm = (DefaultTableModel) tablaEmpleadosEmp.getModel();
        dtm.setRowCount(0);
        List<InformacionLaboral> infoLab = controlador.infoLab(e);
        for (InformacionLaboral lista : infoLab) {
            dtm.addRow(new Object[] { lista.getEgresado().getNombre(),
                    lista.getEgresado().getCodigoPrograma().getNomPrograma(), lista.getCargo(),
                    lista.getFechaIngreso() });
        }
    } catch (Exception exc) {
        exc.printStackTrace();
    }
}

From source file:User.Interface.SupplierAdminRole.ReviewSalesJPanel.java

private void displayData() {
    try {/*from   www  . j a va2  s. c o m*/

        //check if supplier has products
        if (supplierAdminOrganization.getMedicalDeviceCatalog().getMedicalDeviceList().size() < 1) {
            JOptionPane.showMessageDialog(this, "No products avaiailable from supplier");
            return;
        }

        int rowCount = productjTable.getRowCount();
        DefaultTableModel model = (DefaultTableModel) productjTable.getModel();
        for (int i = rowCount - 1; i >= 0; i--) {
            model.removeRow(i);
        }

        double totalSaleAmt = 0;
        int topSoldProductID = 1;

        for (MedicalDevice md : supplierAdminOrganization.getMedicalDeviceCatalog().getMedicalDeviceList()) {
            Object row[] = new Object[4];
            row[0] = md;
            row[1] = md.getDeviceId();
            row[2] = md.getSoldQuantity();
            double totalProductSale = (md.getPrice() * md.getSoldQuantity());
            row[3] = totalProductSale;
            model.addRow(row);

            totalSaleAmt = totalSaleAmt + totalProductSale;
            if (md.getSoldQuantity() > supplierAdminOrganization.getMedicalDeviceCatalog()
                    .getMedicalDeviceList().get(topSoldProductID - 1).getSoldQuantity()) {
                topSoldProductID = md.getDeviceId();
            }
        }

        if (totalSaleAmt > 0) {
            topSoldjTextField.setText(supplierAdminOrganization.getMedicalDeviceCatalog().getMedicalDeviceList()
                    .get(topSoldProductID - 1).getDeviceName());
            totalSalejTextField.setText(String.valueOf(totalSaleAmt));
        } else {
            topSoldjTextField.setText("None");
            totalSalejTextField.setText("0");
        }

    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "An error occurred");
    }
}

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  w w. ja v 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:gdt.jgui.tool.JEntityEditor.java

private void pasteTable(Core[] ca) {
    try {//from  www . ja  va2 s. c o  m
        JScrollPane scrollPane = (JScrollPane) tabbedPane.getSelectedComponent();
        JTable table = (JTable) scrollPane.getViewport().getView();
        DefaultTableModel model = (DefaultTableModel) table.getModel();
        int cnt = ca.length;
        if (cnt < 1)
            return;
        for (int i = 0; i < cnt; i++)
            model.addRow(new String[] { ca[i].type, ca[i].name, ca[i].value });
    } catch (Exception e) {
        LOGGER.severe(e.toString());
    }
}

From source file:User.Interface.InventoryAdminRole.InventoryAdminWorkAreaJPanel.java

private void populateDeliveryTable() {
    int rowCount = deliveryJTable.getRowCount();
    DefaultTableModel dtm = (DefaultTableModel) deliveryJTable.getModel();

    //delete all the previous rows
    for (int i = rowCount - 1; i >= 0; i--) {
        dtm.removeRow(i);//from   ww w.  j ava2 s  . co m
    }

    for (Order o : inventoryEnterprise.getOrderDelivery().getOrderList()) {
        Object[] row = new Object[1];
        row[0] = o;
        dtm.addRow(row);
    }
}

From source file:com.neu.css.view.ViewPatientDetailsJPanel.java

/**
 * populate the table with the vital sign history object
 *//*from w w  w  .  ja  v  a  2  s .c  om*/
private void populateTable() {
    DefaultTableModel defaultTableModel = (DefaultTableModel) jTable1.getModel();
    defaultTableModel.setRowCount(0);
    VitalSignHistory vitalSignHistory = patient.getVitalSignHistory();
    if (null != vitalSignHistory) {
        ArrayList<VitalSign> vitalSignList = vitalSignHistory.getVitalSignList();
        for (VitalSign vitalSign : vitalSignList) {
            Object[] rows = new Object[2];
            rows[0] = vitalSign;
            rows[1] = (String) checkSymtoms(vitalSign);
            defaultTableModel.addRow(rows);
        }
    }
}

From source file:userinterface.InventoryRole.InventoryWorkAreaJPanel.java

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

    model.setRowCount(0);//  w  w w . j  a  v a 2 s.  com
    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 source file:com.mirth.connect.client.ui.panels.connectors.PollingSettingsPanel.java

public void setProperties(PollConnectorProperties properties) {
    scheduleTypeComboBox.removeActionListener(scheduleTypeActionListener);

    clearProperties();/*from   w ww  .  j a  v a  2s  .c  om*/

    if (properties.getPollingType().equals(PollingType.INTERVAL)) {
        String frequencyType = POLLING_FREQUENCY_MILLISECONDS;
        int frequency = properties.getPollingFrequency();

        if (frequency % 3600000 == 0) {
            frequency /= 3600000;
            frequencyType = POLLING_FREQUENCY_HOURS;
        } else if (frequency % 60000 == 0) {
            frequency /= 60000;
            frequencyType = POLLING_FREQUENCY_MINUTES;
        } else if (frequency % 1000 == 0) {
            frequency /= 1000;
            frequencyType = POLLING_FREQUENCY_SECONDS;
        }

        pollingFrequencyField.setText(String.valueOf(frequency));
        pollingFrequencyTypeComboBox.setSelectedItem(frequencyType);
    } else if (properties.getPollingType().equals(PollingType.TIME)) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm aa");
        Calendar timeCalendar = Calendar.getInstance();
        timeCalendar.set(Calendar.HOUR_OF_DAY, properties.getPollingHour());
        timeCalendar.set(Calendar.MINUTE, properties.getPollingMinute());
        pollingTimePicker.setDate(dateFormat.format(timeCalendar.getTime()));
    } else if (properties.getPollingType().equals(PollingType.CRON)) {
        List<CronProperty> cronJobs = properties.getCronJobs();
        if (cronJobs != null && cronJobs.size() > 0) {
            DefaultTableModel model = (DefaultTableModel) cronJobsTable.getModel();
            model.setNumRows(0);

            for (CronProperty property : cronJobs) {
                model.addRow(new Object[] { property.getExpression(), property.getDescription() });
            }

            deleteJobButton.setEnabled(true);
        }
    }

    nextFireTimeProperties = properties.clone();

    String pollingType = properties.getPollingType().getDisplayName();
    yesStartPollRadioButton.setSelected(properties.isPollOnStart());

    scheduleTypeComboBox.setSelectedItem(pollingType);

    enableComponents(pollingType);
    cachedAdvancedConnectorProperties = properties.getPollConnectorPropertiesAdvanced();
    scheduleTypeComboBox.addActionListener(scheduleTypeActionListener);
}