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:Sales.TabbedPaneWin.java

private void ClearCartBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearCartBtnActionPerformed
    DefaultTableModel model = (DefaultTableModel) clientCartTable.getModel();

    //removing all rows in the dynamic model
    model.setRowCount(0);
    totAmountLbl1.setText("00.00");

    //visibleing Jbuttons
    if (clientCartTable.getRowCount() == 0) {
        removeSelectedBtn.setEnabled(false);
        ClearCartBtn.setEnabled(false);/*  w  ww .j  a v  a 2  s  .  c o  m*/
    } else {
        removeSelectedBtn.setEnabled(true);
        ClearCartBtn.setEnabled(true);
    }
}

From source file:com.osparking.attendant.AttListForm.java

/**
 * Update attendant listing table by accessing database table.
 * It also //from ww w  .j  a  v a2  s .  c om
 * @return 
 */
private int loadAttendantTable(String newID) {
    DefaultTableModel model = (DefaultTableModel) usersTable.getModel();
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    StringBuilder sb = new StringBuilder();
    sb.append("Select id as 'User ID', name as 'Name', ");
    sb.append("if(isManager, 'Y', 'N') as 'Manager', ");
    sb.append("cellphone as 'Cell', phone as 'Phone', email as 'E-mail', ");
    sb.append("date_format(creationTime, '%Y-%m-%d') as 'Created', ");
    sb.append("date_format(lastModiTime, '%Y-%m-%d') as 'Modified' ");
    sb.append("from users_osp");

    prevSearchColumn = currSearchColumn;
    prevSearchString = currSearchString;
    if (currSearchString.length() > 0) {
        if (currSearchColumn == LOGIN_ID_LABEL) {
            sb.append(" Where ID like ? ");
        } else {
            sb.append(" Where Name like ? ");
        }
        if (newID.length() > 0) {
            sb.append("or (ID = ?)");
        }
    }

    try {
        conn = JDBCMySQL.getConnection();
        pstmt = conn.prepareStatement(sb.toString());

        int index = 1;

        if (currSearchString.length() > 0) {
            pstmt.setString(index++, "%" + currSearchString + "%");
            if (newID.length() > 0) {
                pstmt.setString(index++, newID);
            }
        }
        rs = pstmt.executeQuery();

        model.setRowCount(0);
        while (rs.next()) {
            model.addRow(new Object[] { rs.getString("User ID"), rs.getString("Name"), rs.getString("Manager"),
                    rs.getString("Cell"), rs.getString("Phone"), rs.getString("E-mail"),
                    rs.getString("Created"), rs.getString("Modified") });
        }
    } catch (Exception ex) {
        logParkingException(Level.SEVERE, ex, "(refresh user list displaying table)");
    } finally {
        closeDBstuff(conn, pstmt, rs, "(refresh user list displaying table)");
        adjustTableHeight(usersTable);
        countValue.setText(String.valueOf(usersTable.getRowCount()));
        if (newID.length() > 0 && newIDnotSatisfySearchCondition(newID)) {
            searchButton.setEnabled(true);
        } else {
            searchButton.setEnabled(false);
        }

        return model.getRowCount();
    }
}

From source file:com.smanempat.controller.ControllerEvaluation.java

private double[][] evaluationModel(JTable tableResult, JTable tableConfMatrix, JLabel totalAccuracy,
        JTable tableTahunTesting, JTable tableDataSetTesting, String[] knnValue, int i, int[] tempK,
        JPanel panelChart) throws SQLException {
    int actIPA = 0;
    int actIPS = 0;
    int trueIPA = 0;
    int falseIPA = 0;
    int trueIPS = 0;
    int falseIPS = 0;

    double recIPA;
    double recIPS;
    double preIPA;
    double preIPS;
    double accuracy;

    DefaultTableModel tableModelRes = new DefaultTableModel();
    tableModelRes = (DefaultTableModel) tableResult.getModel();
    String[] tempJurusan = getJurusanTest(tableTahunTesting, tableDataSetTesting);

    for (int j = 0; j < tableDataSetTesting.getRowCount(); j++) {
        String nis = tableDataSetTesting.getValueAt(j, 0).toString();
        String jurusan = tempJurusan[j];
        String classified = knnValue[j];
        Object[] tableContent = { nis, jurusan, classified };
        tableModelRes.addRow(tableContent);
        tableResult.setModel(tableModelRes);
    }/*from w  ww  .jav  a  2 s.co  m*/

    /*Hitung Jumlah Data Actual IPA dan IPS*/
    for (int j = 0; j < tempJurusan.length; j++) {
        if (tempJurusan[j].equals("IPA")) {
            actIPA = actIPA + 1;
        } else if (tempJurusan[j].equals("IPS")) {
            actIPS = actIPS + 1;
        }
    }

    /*Hitung Jumlah Data Classified IPA dan IPS*/
    for (int j = 0; j < knnValue.length; j++) {
        if (tableResult.getValueAt(j, 1).equals("IPA")) {
            if (tableResult.getValueAt(j, 1).equals(tableResult.getValueAt(j, 2))) {
                trueIPA = trueIPA + 1;
            } else {
                falseIPS = falseIPS + 1;
            }
        } else if (tableResult.getValueAt(j, 1).equals("IPS")) {
            if (tableResult.getValueAt(j, 1).equals(tableResult.getValueAt(j, 2))) {
                trueIPS = trueIPS + 1;
            } else {
                falseIPA = falseIPA + 1;
            }
        }
    }

    /*Hitung Nilai Recall, Precision, dan Accuracy*/
    preIPA = (double) trueIPA / (trueIPA + falseIPA);
    preIPS = (double) trueIPS / (trueIPS + falseIPS);
    recIPA = (double) trueIPA / (trueIPA + falseIPS);
    recIPS = (double) trueIPS / (trueIPS + falseIPA);
    accuracy = (double) (trueIPA + trueIPS) / (trueIPA + trueIPS + falseIPA + falseIPS);

    /*Tampung Nilai Recall, Precision, dan Accuracy*/
    double[][] tempEval = new double[3][tempK.length];
    tempEval[0][i] = accuracy;
    tempEval[1][i] = recIPA;
    tempEval[2][i] = preIPA;

    /*Set Nilai TF, TN, FP, FN ke Tabel Confusion Matrix*/
    tableConfMatrix.setValueAt("Actual IPA", 0, 0);
    tableConfMatrix.setValueAt("Actual IPS", 1, 0);
    tableConfMatrix.setValueAt("Class Precision", 2, 0);
    tableConfMatrix.setValueAt(trueIPA, 0, 1);
    tableConfMatrix.setValueAt(falseIPS, 0, 2);
    tableConfMatrix.setValueAt(falseIPA, 1, 1);
    tableConfMatrix.setValueAt(trueIPS, 1, 2);

    /*Set Nilai Recall, Precision, dan Accuracy ke Tabel Confusion Matrix*/
    if (Double.isNaN(preIPA)) {
        tableConfMatrix.setValueAt("NaN" + " %", 2, 1);
    } else {
        tableConfMatrix.setValueAt(df.format(preIPA * 100) + " %", 2, 1);
    }
    if (Double.isNaN(preIPS)) {
        tableConfMatrix.setValueAt("NaN" + " %", 2, 2);
    } else {
        tableConfMatrix.setValueAt(df.format(preIPS * 100) + " %", 2, 2);
    }
    if (Double.isNaN(recIPA)) {
        tableConfMatrix.setValueAt("NaN" + " %", 0, 3);
    } else {
        tableConfMatrix.setValueAt(df.format(recIPA * 100) + " %", 0, 3);
    }
    if (Double.isNaN(recIPS)) {
        tableConfMatrix.setValueAt("NaN" + " %", 1, 3);
    } else {
        tableConfMatrix.setValueAt(df.format(recIPS * 100) + " %", 1, 3);
    }
    if (Double.isNaN(accuracy)) {
        totalAccuracy.setText("Overall Accuracy is " + "NaN" + " %");
    } else {
        totalAccuracy.setText("Overall Accuracy is " + df.format(accuracy * 100) + " %");
    }

    tableModelRes.setRowCount(0);

    return tempEval;
}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void btnMaterialSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMaterialSaveActionPerformed
    JSONObject json = new JSONObject();
    JSONArray items = new JSONArray();
    String data = this.currentEntry.getMaterial();
    try {//from  www.  j  a v a  2s . c o  m
        if (data != null && !data.equals("")) {
            JSONObject jsonOld = new JSONObject(data);
            items = (JSONArray) jsonOld.getJSONArray("items");
        }
        JSONObject dataset = new JSONObject();
        Date now = new Date();
        String time = new SimpleDateFormat("HH:mm").format(now);
        dataset.put("time", time);
        if (this.cbProductPolymer.getSelectedIndex() != 0) {
            Polymer polymer = ((Polymer) ((ComboBoxItem) this.cbProductPolymer.getSelectedItem()).getItem());
            dataset.put("polymer", polymer.getGrade() + "/" + polymer.getCompany());
        } else {
            dataset.put("polymer", "");
        }
        if (this.cbProductAdditive1.getSelectedIndex() != 0) {
            Additive additive1 = ((Additive) ((ComboBoxItem) this.cbProductAdditive1.getSelectedItem())
                    .getItem());
            dataset.put("additive1", additive1.getGrade() + "/" + additive1.getCompany());
        } else {
            dataset.put("additive1", "");
        }
        if (this.cbProductAdditive2.getSelectedIndex() != 0) {
            Additive additive2 = ((Additive) ((ComboBoxItem) this.cbProductAdditive2.getSelectedItem())
                    .getItem());
            dataset.put("additive2", additive2.getGrade() + "/" + additive2.getCompany());
        } else {
            dataset.put("additive2", "");
        }
        if (this.cbProductAdditive3.getSelectedIndex() != 0) {
            Additive additive3 = ((Additive) ((ComboBoxItem) this.cbProductAdditive3.getSelectedItem())
                    .getItem());
            dataset.put("additive3", additive3.getGrade() + "/" + additive3.getCompany());
        } else {
            dataset.put("additive3", "");
        }
        dataset.put("polymer_batch1", this.txtPolymerBatchA.getText());
        dataset.put("polymer_batch2", this.txtPolymerBatchB.getText());
        dataset.put("additive1_batch1", this.txtAdditiveABatchA.getText());
        dataset.put("additive1_batch2", this.txtAdditiveABatchB.getText());
        dataset.put("additive2_batch1", this.txtAdditiveBBatchA.getText());
        dataset.put("additive2_batch2", this.txtAdditiveBBatchB.getText());
        dataset.put("additive3_batch1", this.txtAdditiveCBatchA.getText());
        dataset.put("additive3_batch2", this.txtAdditiveCBatchB.getText());
        items.put(dataset);
        json.put("items", items);
        this.currentEntry.setMaterial(json.toString());
        this.entryService.UpdateEntity(currentEntry);

        DefaultTableModel modelMaterial = (DefaultTableModel) this.tblMaterial.getModel();
        modelMaterial.setRowCount(0);
        FillMaterialTable(json.toString());

        this.cbProductPolymer.setSelectedIndex(0);
        this.cbProductAdditive1.setSelectedIndex(0);
        this.cbProductAdditive2.setSelectedIndex(0);
        this.cbProductAdditive3.setSelectedIndex(0);
        txtPolymerBatchA.setText("");
        txtPolymerBatchB.setText("");
        txtAdditiveABatchA.setText("");
        txtAdditiveBBatchA.setText("");
        txtAdditiveCBatchA.setText("");
        txtAdditiveABatchB.setText("");
        txtAdditiveBBatchB.setText("");
        txtAdditiveCBatchB.setText("");

    } catch (JSONException ex) {
        AppHelper.Logger.error("Json fail: " + data, ex);
    }

}

From source file:com.cch.aj.entryrecorder.frame.MainJFrame.java

private void UpdateEntryForm() {
    List<Record> records = this.recordService.GetAllEntitiesByKeyAndRecord(RecordKey.ALL,
            this.currentEntry.getId());
    //load images
    if (currentEntry.getMouldId().getImageBoreA() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageBoreA(), this.pnlBoreImage1, 75);
    } else {//from w  w w.j  a v  a 2 s.  c o m
        AppHelper.DisplayImageFromResource("/b1.png", this.pnlBoreImage1, 75);
    }
    if (currentEntry.getMouldId().getImageBoreB() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageBoreB(), this.pnlBoreImage2, 75);
    } else {
        AppHelper.DisplayImageFromResource("/b2.png", this.pnlBoreImage2, 75);
    }
    if (currentEntry.getMouldId().getImageNeck() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageNeck(), this.pnlNeckImage, 75);
    } else {
        AppHelper.DisplayImageFromResource("/b3.png", this.pnlNeckImage, 75);
    }
    if (currentEntry.getMouldId().getImageTap() != null) {
        AppHelper.DisplayImage(currentEntry.getMouldId().getImageTap(), this.pnlTapImage, 75);
    } else {
        AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlTapImage, 75);
    }
    if (currentEntry.getProductId().getDgnondg() != null && currentEntry.getProductId().getDgnondg() == 0) {
        if (currentEntry.getMouldId().getImageDg() != null) {
            AppHelper.DisplayImage(currentEntry.getMouldId().getImageDg(), this.pnlWallImage, 75);
        } else {
            AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlWallImage, 75);
        }
    } else {
        if (currentEntry.getMouldId().getImageNonDg() != null) {
            AppHelper.DisplayImage(currentEntry.getMouldId().getImageNonDg(), this.pnlWallImage, 75);
        } else {
            AppHelper.DisplayImageFromResource("/no_photo_small.png", this.pnlWallImage, 75);
        }
    }
    //info
    UpdateProductInfo(this.currentEntry);
    //weight
    this.labWeightStaff.setVisible(false);
    this.txtWeightStaff.setVisible(false);
    datasetWeight = new DefaultCategoryDataset();

    List<Record> recordsWeight = records.stream().filter(x -> x.getRecordKey().equals("PRODUCT_WEIGHT"))
            .collect(Collectors.toList());
    DefaultTableModel modelWeight = (DefaultTableModel) this.tblWeight.getModel();
    modelWeight.setRowCount(0);
    for (Record record : recordsWeight) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        datasetWeight.addValue(record.getNumberValue(), "Weight", time);
        modelWeight.addRow(new Object[] { time, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblWeight.getModel()).fireTableDataChanged();
    JFreeChart chartWeight = ChartFactory.createLineChart("Product Weight (grams)", "", "", datasetWeight,
            PlotOrientation.VERTICAL, false, true, false);
    ChartPanel cpWeight = new ChartPanel(chartWeight);
    this.pnlChartWeight.removeAll();
    this.pnlChartWeight.add(cpWeight, gridBagConstraints);
    //wall
    List<Record> recordsWall = records.stream().filter(x -> x.getRecordKey().startsWith("WALL_"))
            .collect(Collectors.toList());
    DefaultTableModel modelWall = (DefaultTableModel) this.tblWall.getModel();
    modelWall.setRowCount(0);
    for (Record record : recordsWall) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelWall.addRow(new Object[] { time, name, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblWall.getModel()).fireTableDataChanged();
    //Tap
    datasetTap = new DefaultCategoryDataset();

    List<Record> recordsTap = records.stream().filter(x -> x.getRecordKey().equals("TAP_POSITION"))
            .collect(Collectors.toList());
    DefaultTableModel modelTap = (DefaultTableModel) this.tblTap.getModel();
    modelTap.setRowCount(0);
    for (Record record : recordsTap) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        datasetTap.addValue(record.getNumberValue(), "Tap", time);
        modelTap.addRow(new Object[] { time, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblTap.getModel()).fireTableDataChanged();
    JFreeChart chartTap = ChartFactory.createLineChart("Tap Positio", "", "", datasetTap,
            PlotOrientation.VERTICAL, false, true, false);
    ChartPanel cpTap = new ChartPanel(chartTap);
    this.pnlChartTap.removeAll();
    this.pnlChartTap.add(cpTap, gridBagConstraints);
    //Bore
    List<Record> recordsBore = records.stream().filter(x -> x.getRecordKey().startsWith("THREAD_"))
            .collect(Collectors.toList());
    DefaultTableModel modelBore = (DefaultTableModel) this.tblBore.getModel();
    modelBore.setRowCount(0);
    for (Record record : recordsBore) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelBore.addRow(new Object[] { time, name, record.getNumberValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblBore.getModel()).fireTableDataChanged();
    if (this.currentEntry.getProductId() != null
            && this.currentEntry.getProductId().getClosureType().equals("TWIN")) {
        this.txtBore11.setVisible(true);
        this.txtBore21.setVisible(true);
        this.txtNeck1.setVisible(true);
        this.txtBoreStaff1.setVisible(true);
        this.btnBore1.setVisible(true);
    } else {
        this.txtBore11.setVisible(false);
        this.txtBore21.setVisible(false);
        this.txtNeck1.setVisible(false);
        this.txtBoreStaff1.setVisible(false);
        this.btnBore1.setVisible(false);
    }
    //Check
    List<Record> recordsCheck = records.stream().filter(x -> x.getRecordKey().startsWith("CHECK_"))
            .collect(Collectors.toList());
    DefaultTableModel modelCheck = (DefaultTableModel) this.tblCheck.getModel();
    modelCheck.setRowCount(0);
    for (Record record : recordsCheck) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        String name = record.getRecordKey();
        modelCheck.addRow(new Object[] { time, name, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblCheck.getModel()).fireTableDataChanged();
    //Drop
    List<Record> recordsDrop = records.stream().filter(x -> x.getRecordKey().startsWith("DROP_"))
            .collect(Collectors.toList());
    DefaultTableModel modelDrop = (DefaultTableModel) this.tblDrop.getModel();
    modelDrop.setRowCount(0);
    for (Record record : recordsDrop) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String name = record.getRecordKey();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        modelDrop.addRow(new Object[] { time, name, record.getStringValue(), pass, staff });
    }
    ((AbstractTableModel) this.tblDrop.getModel()).fireTableDataChanged();
    //Bung
    List<Record> recordsBung = records.stream().filter(x -> x.getRecordKey().equals("BUNG"))
            .collect(Collectors.toList());
    DefaultTableModel modelBung = (DefaultTableModel) this.tblBung.getModel();
    modelBung.setRowCount(0);
    for (Record record : recordsBung) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        String pass = record.getIsPass() == null ? "" : record.getIsPass();
        modelBung.addRow(new Object[] { time, record.getStringValue(), pass, staff });
    }
    //Cycle
    List<Record> recordsCycle = records.stream().filter(x -> x.getRecordKey().equals("CYCLE"))
            .collect(Collectors.toList());
    DefaultTableModel modelCycle = (DefaultTableModel) this.tblCycle.getModel();
    modelCycle.setRowCount(0);
    for (Record record : recordsCycle) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String staff = record.getStaff() == null ? "" : record.getStaff();
        modelCycle.addRow(new Object[] { time, record.getStringValue(), staff });
    }
    //Seconds
    float totalSeconds = 0f;
    List<Record> recordsSeconds = records.stream().filter(x -> x.getRecordKey().equals("SECONDS"))
            .collect(Collectors.toList());
    DefaultTableModel modelSeconds = (DefaultTableModel) this.tblSeconds.getModel();
    modelSeconds.setRowCount(0);
    for (Record record : recordsSeconds) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        modelSeconds.addRow(new Object[] { time, record.getNumberValue() });
        totalSeconds += record.getNumberValue();
    }
    this.labSecondsTotal.setText(Float.toString(totalSeconds));
    //Rejects
    float totalRejects = 0f;
    List<Record> recordsRejects = records.stream().filter(x -> x.getRecordKey().equals("REJECTS"))
            .collect(Collectors.toList());
    DefaultTableModel modelRejects = (DefaultTableModel) this.tblRejects.getModel();
    modelRejects.setRowCount(0);
    for (Record record : recordsRejects) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        modelRejects.addRow(new Object[] { time, record.getNumberValue() });
        totalRejects += record.getNumberValue();
    }
    this.labRejectsTotal.setText(Float.toString(totalRejects));
    //material
    this.FillPolymerComboBox(this.cbProductPolymer, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive1, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive2, 0);
    this.FillAdditiveComboBox(this.cbProductAdditive3, 0);
    DefaultTableModel modelMaterial = (DefaultTableModel) this.tblMaterial.getModel();
    modelMaterial.setRowCount(0);
    if (currentEntry.getMaterial() != null && !currentEntry.getMaterial().equals("")) {
        FillMaterialTable(currentEntry.getMaterial());
    }
    txtPolymerBatchA.setText("");
    txtPolymerBatchB.setText("");
    txtAdditiveABatchA.setText("");
    txtAdditiveBBatchA.setText("");
    txtAdditiveCBatchA.setText("");
    txtAdditiveABatchB.setText("");
    txtAdditiveBBatchB.setText("");
    txtAdditiveCBatchB.setText("");
    //staff
    this.FillStaffComboBox(this.cbSupervisor1,
            currentEntry.getSupervisor1() != null ? currentEntry.getSupervisor1().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbSupervisor2,
            currentEntry.getSupervisor2() != null ? currentEntry.getSupervisor2().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbSupervisor3,
            currentEntry.getSupervisor3() != null ? currentEntry.getSupervisor3().getId() : 0, "SUPERVISOR");
    this.FillStaffComboBox(this.cbTechnician1,
            currentEntry.getTechnician1() != null ? currentEntry.getTechnician1().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbTechnician2,
            currentEntry.getTechnician2() != null ? currentEntry.getTechnician2().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbTechnician3,
            currentEntry.getTechnician3() != null ? currentEntry.getTechnician3().getId() : 0, "TECHNICIAN");
    this.FillStaffComboBox(this.cbWorker1,
            currentEntry.getWorker1() != null ? currentEntry.getWorker1().getId() : 0, "PROCESS WORKER");
    this.FillStaffComboBox(this.cbWorker2,
            currentEntry.getWorker2() != null ? currentEntry.getWorker2().getId() : 0, "PROCESS WORKER");
    this.FillStaffComboBox(this.cbWorker3,
            currentEntry.getWorker3() != null ? currentEntry.getWorker3().getId() : 0, "PROCESS WORKER");
    //Leak
    List<Record> recordsLeak = records.stream()
            .filter(x -> x.getRecordKey().startsWith("DROP_") || x.getRecordKey().equals("ANY_LEAK"))
            .collect(Collectors.toList());
    DefaultTableModel modelLeak = (DefaultTableModel) this.tblLeak.getModel();
    modelLeak.setRowCount(0);
    for (Record record : recordsLeak) {
        String time = new SimpleDateFormat("HH:mm").format(record.getCreatedTime());
        String name = record.getRecordKey();
        modelLeak.addRow(new Object[] { time, name, record.getStringValue() });
    }
    ((AbstractTableModel) this.tblLeak.getModel()).fireTableDataChanged();
    this.txtLeakNotes.setVisible(false);
    //quantity
    this.txtPalletQuantity.setText(
            currentEntry.getPalletQuantity() == null ? "0" : currentEntry.getPalletQuantity().toString());
    this.txtOtherQuantity.setText(
            currentEntry.getOtherQuantity() == null ? "0" : currentEntry.getOtherQuantity().toString());
    this.txtPalletProducedA.setText(
            currentEntry.getPalletProducedA() == null ? "0" : currentEntry.getPalletProducedA().toString());
    this.txtPalletProducedB.setText(
            currentEntry.getPalletProducedB() == null ? "0" : currentEntry.getPalletProducedB().toString());
    int a1 = 0;
    int a2 = 0;
    int b1 = 0;
    int b2 = 0;
    a1 = Integer.parseInt(this.txtPalletProducedA.getText());
    b1 = Integer.parseInt(this.txtPalletProducedB.getText());
    a2 = Integer.parseInt(this.txtPalletQuantity.getText());
    b2 = Integer.parseInt(this.txtOtherQuantity.getText());
    this.labQuantityTotal.setText(Integer.toString((a1 * a2) + (b1 * b2)));
}

From source file:interfaces.InterfazPrincipal.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    String factura_id = jTextField_BuscarFactura_ID.getText();
    String cliente_id = jTextField_BuscarFactura_Cliente.getText();
    ControladorFactura controladorFactura = new ControladorFactura();
    String restriccion = "";
    if (!factura_id.equals("")) {
        restriccion += " where factura_id like '%" + factura_id + "%'";
        if (!cliente_id.equals("")) {
            restriccion += " or cliente_id like '%" + cliente_id + "%'";
        }//from  w ww  .  j ava  2  s .  com
    } else {
        if (!cliente_id.equals("")) {
            restriccion += " where cliente_id like '%" + cliente_id + "%'";
        }
    }

    //String restriccion2 = " where factura_id like '%"+factura_id+"%' or cliente_id like '%"+cliente_id+"%'";
    ArrayList<Factura> listaFactura = controladorFactura.getFactura(restriccion);

    DefaultTableModel modelo = (DefaultTableModel) TablaDeBuscarFactura.getModel();

    for (int i = 0; i < modelo.getRowCount(); i++) {
        modelo.removeRow(i);
    }
    modelo.setRowCount(0);
    ControladorCliente controladorCliente = new ControladorCliente();
    for (int i = 0; i < listaFactura.size(); i++) {
        Factura factura = listaFactura.get(i);
        Object[] fila = new Object[6];
        fila[0] = (i + 1);
        fila[1] = factura.getFactura_id();
        fila[2] = factura.getFecha();

        Cliente cliente = controladorCliente.obtenerClientePorID(factura.getCliente_id());
        fila[3] = cliente.getNombre();
        fila[4] = factura.getEstado();

        Double valorFactura = factura.getValor();
        NumberFormat formatter = new DecimalFormat("#0");

        fila[5] = formatter.format(valorFactura);
        //button.setText("<HTML>Click the <FONT color=\"#000099\"><U>link "+i+"</U></FONT>"+ " to go to the Java website.</HTML>");
        modelo.addRow(fila);

    }

    TablaDeBuscarFactura.setModel(modelo);
}

From source file:interfaces.InterfazPrincipal.java

public void generarTablaUsuarios() {
    //tablaUsuariosDelSistema
    ControladorUsuarios controladorUsuarios = new ControladorUsuarios();
    ArrayList<Usuarios> listaUsuarios = controladorUsuarios.obtenerTodosUsuarios();

    DefaultTableModel modeloTabla = (DefaultTableModel) tablaUsuariosDelSistema.getModel();

    for (int i = 0; i < modeloTabla.getRowCount(); i++) {
        modeloTabla.removeRow(i);//  w  ww . j a  va  2 s. c o  m
    }
    modeloTabla.setRowCount(0);

    for (int i = 0; i < listaUsuarios.size(); i++) {
        Usuarios usuarioActual = listaUsuarios.get(i);

        Object[] rowData = new Object[3];
        rowData[0] = usuarioActual.getLogin();
        rowData[1] = usuarioActual.getCreation_data();

        char habilitado = usuarioActual.getStatus();

        if (habilitado == 'e') {
            rowData[2] = "Habilitado";
        } else {
            rowData[2] = "Inhablitado";
        }

        modeloTabla.addRow(rowData);
    }
    tablaUsuariosDelSistema.setModel(modeloTabla);

}

From source file:interfaces.InterfazPrincipal.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    // TODO add your handling code here:
    String identificacion = jTextFieldNitProveedores.getText();
    String nombre = jTextFieldNombreProveedores.getText();
    int identificacionClienteInt = 0;
    try {/*from  w w  w  . ja v a2  s.c o m*/

        ControladorProveedores controladorProveedores = new ControladorProveedores();

        ArrayList<Proveedores> listaDeProveedores = controladorProveedores.obtenerProveedores(identificacion,
                nombre);

        //Agregar filas
        DefaultTableModel modelo = (DefaultTableModel) TablaDeProveedores.getModel();

        for (int i = 0; i < modelo.getRowCount(); i++) {
            modelo.removeRow(i);
        }
        modelo.setRowCount(0);
        for (int i = 0; i < listaDeProveedores.size(); i++) {
            Proveedores proveedor = listaDeProveedores.get(i);
            Object[] fila = new Object[4];
            fila[0] = proveedor.getIdentificacion();
            fila[1] = proveedor.getNombre();
            //button.setText("<HTML>Click the <FONT color=\"#000099\"><U>link "+i+"</U></FONT>"+ " to go to the Java website.</HTML>");

            fila[3] = "Editar";
            modelo.addRow(fila);

        }

        TablaDeProveedores.setModel(modelo);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "Buscar con campos validos", "Error", JOptionPane.ERROR_MESSAGE);
    }
    //TablaDeProveedores
}

From source file:interfaces.InterfazPrincipal.java

private void BotonBuscarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonBuscarClienteActionPerformed
    // TODO add your handling code here:
    String nombreCliente = nombreClienteBusqueda.getText();
    String identificacionCliente = identificacionClienteBusqueda.getText();
    int identificacionClienteInt = 0;
    try {/*  ww w  . ja va 2 s. c om*/
        if (!identificacionCliente.equals("")) {
            identificacionClienteInt = Integer.parseInt(identificacionCliente);
        }

        ControladorCliente controladorCliente = new ControladorCliente();

        ArrayList<Cliente> listaDeClientes = controladorCliente.obtenerClientes(nombreCliente,
                identificacionClienteInt);

        //Agregar filas
        DefaultTableModel modelo = (DefaultTableModel) TablaDeClientes.getModel();

        for (int i = 0; i < modelo.getRowCount(); i++) {
            modelo.removeRow(i);
        }
        modelo.setRowCount(0);
        for (int i = 0; i < listaDeClientes.size(); i++) {
            Cliente cliente = listaDeClientes.get(i);
            Object[] fila = new Object[4];
            fila[0] = cliente.getCliente_id();
            fila[1] = cliente.getNombre();

            Double montoAPrestar = cliente.getMonto_prestamo();
            NumberFormat formatter = new DecimalFormat("#0");
            fila[2] = formatter.format(montoAPrestar);

            fila[3] = "Editar";
            modelo.addRow(fila);

        }

        TablaDeClientes.setModel(modelo);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this,
                "La identificacin debe ser numrica, por favor ingrese correctamente el dato", "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:interfaces.InterfazPrincipal.java

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
    // TODO add your handling code here:
    String NitProveedor = campoNitBuscarProveedor.getText();
    String buscarNombreProveedor = campoNombreBuscarProveedor.getText();

    String restriccion = " where IDProveedor in ( select ID from Proveedores where 1";

    if (!NitProveedor.equals("")) {
        restriccion += " and ID = " + NitProveedor;
    }/*w  w  w  .ja  v  a 2  s  . c o  m*/

    if (!buscarNombreProveedor.equals("")) {
        restriccion += " and nombre LIKE '\"%" + buscarNombreProveedor + "%\"";
    }

    restriccion += ")";
    ControladorCompraProveedor controladorCompraProveedor = new ControladorCompraProveedor();
    ArrayList<CompraProveedores> listaCompraProveedores = controladorCompraProveedor
            .obtenerCompraProveedoresPorRestriccion(restriccion);

    DefaultTableModel modeloTabla = (DefaultTableModel) tablaMostrarCompras.getModel();

    for (int i = 0; i < modeloTabla.getRowCount(); i++) {
        modeloTabla.removeRow(i);
    }
    modeloTabla.setRowCount(0);

    for (int i = 0; i < listaCompraProveedores.size(); i++) {
        CompraProveedores compraProveedores = listaCompraProveedores.get(i);
        Object[] fila = new Object[4];
        //numero, proveedor, fecha, valor
        fila[0] = compraProveedores.getID();

        ControladorProveedores controladorProveedores = new ControladorProveedores();
        Proveedores proveedores = controladorProveedores
                .obtenerProveedores(String.valueOf(compraProveedores.getIDProveedor()), "").get(0);
        fila[1] = proveedores.getNombre();
        fila[2] = compraProveedores.getFecha();
        fila[3] = compraProveedores.getMontoCompra();

        modeloTabla.addRow(fila);

    }
    tablaMostrarCompras.setModel(modeloTabla);
}