public void populate() { productLines = model.getProductLines(); suppliers = model.getSuppliers(); createMap(); products = model.getProducts(); if (iProductLineList.getItemCount() != 0) { iProductLineList.removeAllItems(); } iProductLineList.addItem(" "); for (ProductLine productLine : productLines) { iProductLineList.addItem(productLine.getProductLineName()); } if (iSupplierList.getItemCount() != 0) { iSupplierList.removeAllItems(); } iSupplierList.addItem(" "); for (Supplier supplier : suppliers) { iSupplierList.addItem(supplier.getSupplierName()); } populateTable(); }
private void populateTable() { while (tableModel.getRowCount() > 0) { tableModel.removeRow(0); } products = model.getProducts(); for (Products product : products) { tableModel.addRow( new Object[] { String.valueOf(product.getProductID()), product.getAddmotoCode(), productLineMap.get(product.getProductLineID()), (product.getDescription() + " " + product.getCharacteristics() + " " + product.getMotors()) .replaceAll("\\s+", " ") .trim(), "PhP " + Formatter.format(product.getUnitPrice()), "PhP " + Formatter.format(product.getSellingPrice()) }); } }