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:UserInterface.ReciepientRole.RecepientRecordJPanel.java

public void populateTable() {
    DefaultTableModel dtm = (DefaultTableModel) recHormonalRecordsJTbl.getModel();

    dtm.setRowCount(0);/*from w w  w .  j ava 2  s  . co m*/
    //System.err.println("the user is "+userAccount);
    //System.err.println("the request list is "+userAccount.getWorkQueue().getWorkRequestList());
    for (Employee recepient : organization.getEmployeeDirectory().getEmployeeList()) {
        if (recepient.getName().equalsIgnoreCase(userAccount.getEmployee().getName())) {
            for (HormonalRecords hr : recepient.getHormonalRecordsHistory().getHormonalRecordsList()) {
                Object row[] = new Object[5];
                row[0] = hr;
                row[1] = hr.getLeutinizingHormoneLevels();
                row[2] = hr.getFollicleStimulatingHormoneLevels();
                row[3] = hr.gethCGLevels();
                row[4] = hr.getTempDropIOT();
                dtm.addRow(row);

            }

        }
    }

}

From source file:musiccrawler.App.java

private void getAllMusic(DefaultTableModel defaultTableModel) {
    List<Music> musics = musicCrawler.getAllMusic();
    if (CollectionUtils.isNotEmpty(musics)) {
        AtomicInteger count = new AtomicInteger();
        musics.forEach(music -> {//from  w ww .j a  v a 2s .c  o m
            Object[] row = { count.getAndIncrement(), music.getId(), music.getTitle(), music.getImage(),
                    music.getUrl(), music.getLyric(), music.getDescription(), music.getStream(),
                    music.getQualityType().toString(), music.getSinger().getName(), music.getSinger().getAge(),
                    music.getSinger().getDescription(), music.getSinger().getAvatar() };
            defaultTableModel.addRow(row);
        });
        tbResult.setModel(defaultTableModel);
        defaultTableModel.fireTableDataChanged();
        tbResult.setVisible(true);
    }
}

From source file:UserInterface.ViewPatientJPanel.java

private void populateTable() {

    DefaultTableModel dtm = (DefaultTableModel) tblVitalSigns.getModel();
    int rowCount = dtm.getRowCount();

    for (int x = rowCount - 1; x >= 0; x--) {
        dtm.removeRow(x);/*from  www  . j  a v  a 2 s.c o  m*/
    }

    for (VitalSign vs : patient.vitalSignHistory.getVitalSignHistory()) {
        Object row[] = new Object[2];
        row[0] = vs;
        row[1] = vs.getState();

        dtm.addRow(row);
    }

}

From source file:musiccrawler.App.java

private void getMusicByOption(Map<String, String> values, DefaultTableModel defaultTableModel) {
    List<Music> musics = musicCrawler.getMusicByOption(values);
    if (!CollectionUtils.isEmpty(musics)) {
        AtomicInteger count = new AtomicInteger();
        musics.forEach(music -> {/*from   w ww.j  a v a  2s .c  o m*/
            Object[] row = { count.getAndIncrement(), music.getId(), music.getTitle(), music.getImage(),
                    music.getUrl(), music.getLyric(), music.getDescription(), music.getStream(),
                    music.getQualityType().toString(), music.getSinger().getName(), music.getSinger().getAge(),
                    music.getSinger().getDescription(), music.getSinger().getAvatar() };
            defaultTableModel.addRow(row);
        });
        tbResult.setModel(defaultTableModel);
        defaultTableModel.fireTableDataChanged();
        tbResult.setVisible(true);
    }
}

From source file:Import.pnl_import_vcf.java

public void setMapTable(JTable table, DefaultTableModel model, String[] selectedFamilies,
        String[] selectedTableFamilies) {
    model.setRowCount(0);// ww  w  . ja va  2 s  . c  o  m
    model.addColumn("Import Column");
    model.addColumn("Map to");
    TableColumn sportColumn = table.getColumnModel().getColumn(1);
    JComboBox comboBox = new JComboBox();
    for (String a : selectedFamilies) {
        comboBox.addItem(a);
    }
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
    for (String b : selectedTableFamilies) {
        String[] tmp = new String[1];
        tmp[0] = b;
        model.addRow(tmp);
    }
}

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

void reloadCompareTable() {
    DefaultTableModel model = JTableUtil.createModel(true, "no", "same", "file name", "external file",
            "src file");
    int index = 0;
    for (CompareFile tmpCompare : compareList) {
        if (tmpCompare.srcSet == null || tmpCompare.srcSet.isEmpty()) {
            model.addRow(new Object[] { //
                    index, //
                    "NA", // 
                    tmpCompare.external.getName(), //
                    tmpCompare.external, //
                    NO_MATCH_FILE //
            });//  w  w  w  . j a v  a  2  s. c  o  m
        } else {
            for (File matchSrcFile : tmpCompare.srcSet) {
                model.addRow(new Object[] { //
                        index, //
                        (tmpCompare.external.length() == matchSrcFile.length() ? "" : "X"), // X=
                        tmpCompare.external.getName(), //
                        tmpCompare.external, //
                        matchSrcFile //
                });
            }
        }
        index++;
    }
    compareTable.setModel(model);
    JTableUtil.newInstance(compareTable).setMaxWidth(50, 50, 300, -1, -1);
}

From source file:com.mirth.connect.connectors.vm.ChannelWriter.java

private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
    DefaultTableModel model = (DefaultTableModel) mapVariablesTable.getModel();

    Vector<String> row = new Vector<String>();
    String name = "Variable ";

    for (int i = 1; i <= mapVariablesTable.getRowCount() + 1; i++) {
        boolean exists = false;
        for (int index = 0; index < mapVariablesTable.getRowCount(); index++) {
            if (((String) mapVariablesTable.getValueAt(index, 0)).equalsIgnoreCase(name + i)) {
                exists = true;/*from ww  w.j  a  v a 2 s. c o m*/
            }
        }

        if (!exists) {
            row.add(name + i);
            break;
        }
    }

    model.addRow(row);

    int rowSelectionNumber = mapVariablesTable.getRowCount() - 1;
    mapVariablesTable.setRowSelectionInterval(rowSelectionNumber, rowSelectionNumber);

    Boolean enabled = deleteButton.isEnabled();
    if (!enabled) {
        deleteButton.setEnabled(true);
    }
    parent.setSaveEnabled(true);
}

From source file:drugsupplychain.neu.css.gui.common.pharmaco.ProductDistributionDetailJPanel.java

/**
 * populate distribution table// w  w  w  . j av a  2s.  c om
 */
private void populateDistributionTable() {
    DefaultTableModel defaultTableModel = (DefaultTableModel) distributionTable.getModel();
    defaultTableModel.setRowCount(0);
    if (null != product) {
        if (null != product.getProductTracker()) {
            for (String id : product.getProductTracker().keySet()) {
                TrackOrganization trackOrganization = product.getProductTracker().get(id);
                if (trackOrganization.getOrganization() instanceof RegionalDistributor) {
                    Object[] rows = new Object[5];
                    rows[0] = trackOrganization.getOrganization().getLocation();
                    rows[1] = trackOrganization;
                    rows[2] = trackOrganization.getOrganization();
                    rows[3] = trackOrganization.getQuantity();
                    rows[4] = trackOrganization.getQuantity() * product.getPrice();
                    defaultTableModel.addRow(rows);
                }
            }
        }
    }
}

From source file:gui.Grafico.java

/**
 *
 * @param expresion/* w w w  .  j ava  2 s  .  c o  m*/
 * @param minX
 * @param maxX
 * <p/>
 * @throws CaracterIlegal
 */
public void graficar(String expresion, double minX, double maxX) throws CaracterIlegal {
    String nombreVariable = "";
    String[] rpn = Procesador.convertirRPN(expresion);

    for (String item : rpn) {
        if (Procesador.esVariable(item)) {
            if (nombreVariable.isEmpty()) {
                nombreVariable = item;
            } else if (!item.equals(nombreVariable)) {
                throw new CaracterIlegal(expresion, 0);
            }
        }
    }

    double[] valoresX = new double[1001];
    double[] valoresY = new double[1001];
    double iteradorDoubleX = minX;
    double pasoDouble = (maxX - minX) / 1000.0;

    for (int i = 0; i < valoresX.length; i++) {
        valoresX[i] = iteradorDoubleX;

        try {
            valoresY[i] = evaluarValor(Arrays.copyOf(rpn, rpn.length), nombreVariable, valoresX[i]);
        } catch (Exception e) {
            valoresY[i] = Double.NaN;
        }

        iteradorDoubleX += pasoDouble;
    }

    double pasoDoubleError = pasoDouble / 2;

    for (int i = 0; i < valoresY.length; i++) {
        if (valoresY[i] == Double.NaN) {
            double izquierdo = evaluarValor(Arrays.copyOf(rpn, rpn.length), nombreVariable,
                    valoresX[i] - pasoDoubleError);
            double derecho = evaluarValor(Arrays.copyOf(rpn, rpn.length), nombreVariable,
                    valoresX[i] + pasoDoubleError);
            valoresY[i] = (izquierdo - derecho) / 2;
        }
    }

    //        System.out.println(Arrays.toString(valoresX));
    //        System.out.println(Arrays.toString(valoresY));
    DefaultTableModel modeloTablaDefecto = (DefaultTableModel) jTable1.getModel();

    if (ultimoNombre.length() > 0) {
        set.removeSeries(nombres.get(ultimoNombre));
        modeloTablaDefecto.setValueAt(false, modeloTablaDefecto.getRowCount() - 1, 0);
    }

    double[][] valores = new double[][] { valoresX, valoresY };
    String funcion = generarNombre() + "(" + nombreVariable + ") = "
            + Procesador.evaluarRPN(Procesador.convertirRPN(expresion)).toString();

    set.addSeries(funcion, valores);
    nombres.put(ultimoNombre, funcion);
    funciones.put(funcion, valores);

    modeloTablaDefecto.addRow(new Object[] { true, funcion });
    jPanel2.repaint();

    setVisible(true);
}

From source file:UserInterface.FinanceRole.TransferToRegSiteJPanel.java

private void populateRegSiteTable(CountryEnterprise objCountryEnterprise) {

    DefaultTableModel dtm = (DefaultTableModel) regSiteJTable.getModel();
    dtm.setRowCount(0);/*from  w w  w.  ja v  a2s . c  o  m*/

    for (RegisteredSiteEnterprise objRegisteredSiteEnterprise : objCountryEnterprise
            .getObjRegisteredSiteDirectory().getRegisteredSiteList()) {

        Object row[] = new Object[2];
        row[0] = objRegisteredSiteEnterprise.getOrganizationID();
        row[1] = objRegisteredSiteEnterprise;

        dtm.addRow(row);

    }
}