private boolean addBrand() throws ClassNotFoundException, SQLException { String brandId = brandIdTextField.getText(); String brand = brandTextField.getText(); if (brand.isEmpty()) { JOptionPane.showMessageDialog(this, "Brand type can't be empty"); isBrandEmpty = true; // isBrandEmpty->true when brandTextField is empty return false; } else { isBrandEmpty = false; // //isBrandEmpty->false when brandTextField is not empty } return BrandController.addBrandCategory(new Brand(brandId, brand)); }
private void getAllBrandTypes() throws ClassNotFoundException, SQLException { ArrayList<Brand> allBrands = BrandController.getAllBrands(); DefaultTableModel dtm = (DefaultTableModel) brandTable.getModel(); dtm.setRowCount(0); for (Brand brand : allBrands) { dtm.addRow(new Object[] {brand.getBrandId(), brand.getBrand()}); } int size = allBrands.size(); if (size != 0) { generateId(allBrands.get(size - 1).getBrandId()); } else { brandIdTextField.setText("B-001"); brandTextField.setText(""); } }