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:gtu._work.ui.RegexCatchReplacer_Ebao.java

/**
 * @param fromPattern//from   w w  w.j  a  v  a  2s  . c  om
 *            ???pattern
 * @param toFormat
 *            ??pattern
 * @param replaceText
 *            ??
 */
void replacer(String fromPattern, String toFormat, String replaceText) {
    try {
        Pattern pattern = Pattern.compile(fromPattern);
        Matcher matcher = pattern.matcher(replaceText);
        Map<String, Integer> tmap = new LinkedHashMap<String, Integer>();
        String tempStr = null;
        for (; matcher.find();) {
            tempStr = toFormat.toString();
            for (int ii = 0; ii <= matcher.groupCount(); ii++) {
                System.out.println(ii + " -- " + matcher.group(ii));
                tempStr = tempStr.replaceAll("#" + ii + "#", Matcher.quoteReplacement(matcher.group(ii)));
                if (!tmap.containsKey(tempStr)) {
                    tmap.put(tempStr, 0);
                }
                tmap.put(tempStr, tmap.get(tempStr) + 1);
            }
        }
        DefaultTableModel model = JTableUtil.createModel(true, "match", "count");
        for (String str : tmap.keySet()) {
            model.addRow(new Object[] { str, tmap.get(str) });
        }
        setTitle("total : " + model.getRowCount());
        resultArea.setModel(model);

        // ebao?
        JTableUtil resultAreaUtil = JTableUtil.newInstance(resultArea);
        DefaultTableModel model2 = JTableUtil.createModel(true, "msgId", "Label");
        boolean isExactSearch = exactEbaoSearchChk.isSelected();
        ebaoTable.setModel(model2);
        for (int ii = 0; ii < model.getRowCount(); ii++) {
            String msgId = (String) resultAreaUtil.getRealValueAt(ii, 0);
            callEbaoMsgId(msgId, isExactSearch);
        }
    } catch (Exception ex) {
        JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(ex.getMessage(), getTitle());
        ex.printStackTrace();
    }
}

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

private void setMapVariableTableValues(List<String> sourceMap) {
    ((DefaultTableModel) mapVariablesTable.getModel()).setRowCount(0);
    DefaultTableModel tableModel = (DefaultTableModel) mapVariablesTable.getModel();

    if (sourceMap != null) {
        for (String entry : sourceMap) {
            tableModel.addRow(new Object[] { entry });
        }/*  w w  w.  j a v  a  2 s . c om*/
    }
}

From source file:com.jtk.medicalrecord.view.panel.InputMedrecPemeriksaanpendukung.java

public void createTableValue() {
    Object[] columnsName = { "Nama File", "Tipe File" };

    DefaultTableModel dtm = new DefaultTableModel(null, columnsName) {
        @Override//from   ww  w. j a  va2 s. c o  m
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    for (PemeriksaanPendukung p : pemeriksaanPendukungs) {
        Object[] o = new Object[2];
        o[0] = p.getPemNmFile();
        o[1] = p.getPemTipeFile();

        dtm.addRow(o);
    }
    tblFile.setModel(dtm);
    CommonHelper.resizeColumnWidth(tblFile);
}

From source file:boundary.ReportProduce.java

private void setSoundmanTbl(String session) {
    DefaultTableModel model = new DefaultTableModel();
    jTable2.setModel(model);//from w  w w  . j ava  2 s  .c om
    model.addColumn("ID");
    model.addColumn("Producer");
    model.addColumn("Mix Tech");
    model.addColumn("Master Tech");

    for (SoundManInSession entry : ReportProduceControl.getSoundmans(Integer.valueOf(session))) {
        model.addRow(new Object[] { entry.getSoundManID(), entry.isProducer(), entry.isMasterTech(),
                entry.isMasterTech() });
    }
}

From source file:cz.muni.fi.mushroomhunter.restclient.AllMushroomsSwingWorker.java

@Override
protected void done() {
    try {//from w w w  . j  a  v a2s  .  c o m
        get();
    } catch (Exception e) {
        restClient.getlMessageMushrooms().setText("ERROR: server is unavailable.");
        return;
    }
    try {
        List<MushroomDto> list = get();
        DefaultTableModel model = (DefaultTableModel) restClient.getTblMushroom().getModel();
        model.setRowCount(0);
        for (int i = 0; i < list.size(); i++) {
            RestClient.getMushroomIDs().add(list.get(i).getId());

            SimpleDateFormat MMMMFormat = new SimpleDateFormat("MMMM", new Locale("en_US"));
            String startOfOccurence = MMMMFormat.format(list.get(i).getStartOfOccurence());
            String endOfOccurence = MMMMFormat.format(list.get(i).getEndOfOccurence());

            model.addRow(new Object[] { list.get(i).getName(), list.get(i).getType().toString(),
                    startOfOccurence, endOfOccurence });
        }
    } catch (ExecutionException ex) {

    } catch (InterruptedException ex) {
        throw new RuntimeException("Operation interrupted", ex);
    }
}

From source file:userinterface.AdministratorWorkArea.TopMedicineJPanel.java

/**
 * Creates new form TopMedicineJPanel//from   w ww .  j av  a  2s . c  o  m
 */
public TopMedicineJPanel(JPanel upc, Enterprise e, UserAccount ua) {
    initComponents();
    userProcessContainer = upc;
    userAccount = ua;
    enterprise = e;

    for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) {
        if (organization instanceof AdminOrganization) {
            org = organization;
            break;
        }
    }
    if (org != null) {
        String maxMed = null;
        int maxQaunt = 0;
        for (WorkRequest request : org.getWorkQueue().getWorkRequestList()) {
            if (request instanceof MedicineWorkRequest) {
                int quant = ((MedicineWorkRequest) request).getQuantityOrdered();
                if (quant > maxQaunt) {
                    maxQaunt = quant;
                    maxMed = ((MedicineWorkRequest) request).getMedicineName();

                }

            }
        }
        DefaultTableModel dtm = (DefaultTableModel) productTable.getModel();

        int rowcount = productTable.getRowCount();

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

        Object row[] = new Object[2];

        row[0] = maxMed == null ? "No Medicines Ordered Yet" : maxMed;
        row[1] = maxQaunt == 0 ? "No Medicines Ordered Yet" : maxQaunt;
        dtm.addRow(row);

    }

}

From source file:view.caja.Despacho.java

public void agregarFila() {
    if (p != null) {
        // { "#", "Producto","Precio","Codigo","Cantidad"}
        DefaultTableModel defModel = (DefaultTableModel) tbCarrito.getModel();
        contador++;/*from   w w  w .j  a v a2  s . c o  m*/
        defModel.addRow(
                new Object[] { contador, p.getNomprod(), p.getPventa(), p.getCodprod(), cant, p.getIdprod() });
        aCobrar = aCobrar + (p.getPventa() * cant);
        jlblACobrarMostrar.setText(Double.toString(aCobrar));
        jlblCantMostrar.setText(Integer.toString(contador));
        //System.out.println(aCobrar);
        btRemoveAll.setEnabled(true);
    }
}

From source file:Vista.VentasCiudad.java

private void jButton_executeGeneralVCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_executeGeneralVCActionPerformed
    String[] nombres = { "Id", "Ciudad", "Total Ventas" };

    String[] filasT = client.consultaGeneralCiudad("0;0", "").split("\\n");

    DefaultTableModel dtm = new DefaultTableModel(nombres, filasT.length);
    dtm = (DefaultTableModel) this.jTable_ConsultaGeneral.getModel();
    this.jTable_ConsultaGeneral.removeAll();

    for (String s : filasT) {
        String[] columnasT = s.split("\\t");
        dtm.addRow(new Object[] { columnasT[0], columnasT[1], columnasT[2] });
    }/*  w  w  w . ja  v  a2  s . co  m*/
}

From source file:co.edu.eam.ingesoft.desarrollo.vista.gui.ReportesEstadisticas.java

/**
 * lista la tabla con todos los datos requeridos
 */// w w w . ja  v a2 s.  co m
public void listarTabla(Empresa e) {
    try {
        DefaultTableModel dtm = (DefaultTableModel) jTtablaEmpresaEgresado.getModel();
        dtm.setRowCount(0);
        List<InformacionLaboral> lista = controlador.listarEgresadosPorEmpresa(e);

        for (InformacionLaboral infoLaboral : lista) {
            dtm.addRow(new Object[] { infoLaboral.getEgresado().getNombre(),
                    infoLaboral.getEgresado().getPrograma(), infoLaboral.getCargo(),
                    infoLaboral.getFechaIngreso() });
        }

    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

}

From source file:UserInterface.CDC.VARESCityReportingJPanel.java

private void populateTable() {
    DefaultTableModel model = (DefaultTableModel) summaryjTable.getModel();
    model.setRowCount(0);//from  www. j a v a2 s .c o  m
    if (business.getStateList() != null) {
        for (CityNetwork city : state.getCityList()) {
            Object[] row = new Object[3];
            row[0] = city;
            row[1] = city.getTotalVaccinesAdministeredInCity();
            row[2] = city.getTotalFailedVaccinesInCity();

            model.addRow(row);
        }

    }

}