public void initializeItem() {
   DefaultComboBoxModel<String> theModel = (DefaultComboBoxModel<String>) itemComboBox.getModel();
   theModel.removeAllElements();
   itemComboBox.addItem("");
   for (MusicalInstrument m : inventoryArr) {
     itemComboBox.addItem(m.getStockCode());
   }
 }
    public void actionPerformed(ActionEvent arg0) {
      boolean ifExist = false;
      tempDescription = description.getText();
      tempStockCode = stockCode.getText();
      tempQtyInStock = getIntValue(qtyInStock);
      tempQtySold = getIntValue(qtySold);
      tempPurchasePrice = getDoubleValue(purchasePrice);
      tempSellingPrice = getDoubleValue(sellingPrice);
      tempNumRented = getIntValue(numberRented);

      for (MusicalInstrument m : inventoryArr) {
        if (m.getStockCode().equals(tempStockCode)) {
          if (tempSellingPrice / tempPurchasePrice >= 1.1) {
            m.setDescription(tempDescription);
            m.setQuantityInStock(tempQtyInStock);
            m.setQuantitySold(tempQtySold);
            m.setPurchasePrice(tempPurchasePrice);
            m.setSellingPrice(tempSellingPrice);
            m.setNumberRented(tempNumRented);
            ifExist = true;
            JOptionPane.showMessageDialog(
                op,
                "Item has been modified sucessfully",
                "Modification completed",
                JOptionPane.INFORMATION_MESSAGE);
          } else
            JOptionPane.showMessageDialog(
                op, "Selling price is too low", "Price error", JOptionPane.INFORMATION_MESSAGE);
        }
      }
      if (!ifExist) {
        if (tempSellingPrice / tempPurchasePrice >= 1.1) {
          inventoryArr.add(
              new MusicalInstrument(
                  tempDescription,
                  tempStockCode,
                  tempQtyInStock,
                  tempQtySold,
                  tempPurchasePrice,
                  tempSellingPrice,
                  tempNumRented));
          JOptionPane.showMessageDialog(
              op,
              "New item has been added to the inventory sucessfully",
              "New inventory",
              JOptionPane.INFORMATION_MESSAGE);
        } else
          JOptionPane.showMessageDialog(
              op, "Selling price is too low", "Price error", JOptionPane.INFORMATION_MESSAGE);
      }
      initializeItem();
    }
 public void updateTxt(ArrayList<MusicalInstrument> arr) throws FileNotFoundException {
   // instrumentData[0], instrumentData[1], stockQty, soldQty, pPrice, sPrice, numRented
   FileOutputStream fileOut = new FileOutputStream(TXTFILE);
   PrintStream out = new PrintStream(fileOut);
   for (MusicalInstrument m : arr)
     out.print(
         "\n"
             + m.getDescription()
             + "|"
             + m.getStockCode()
             + "|"
             + m.getQuantityInStock()
             + "|"
             + m.getQuantitySold()
             + "|"
             + m.getPurchasePrice()
             + "|"
             + m.getSellingPrice()
             + "|"
             + m.getNumberRented());
   out.flush();
   out.close();
 }