title: Is there a way I can configure a Delete JButton to delete selected row in not only the JTable but also Notepad?
body: <p>I am making an inventory system that has the ability of saving the data in .txt format. The GUI has a delete button that gives one the ability of deleting a selected row in a jTable but fails to do so in the .txt file that the credentials were saved before the user deleted the selected row. The save button has successfully been able to replicate data from the JTable to the .txt file.
  Below is the save button and delete button codes respectively:-</p>
  <pre><code>//save button
          JButton btnNewButton = new JButton(&quot;Save&quot;);
          btnNewButton.addMouseListener(new MouseAdapter() {
              @Override
              public void mouseClicked(MouseEvent e) {
  
              }
          });
          btnNewButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  System.out.println(&quot;Clicked&quot;);
                  ProductObject prouct = new ProductObject(textField.getText(), textField_1.getText(),
                          Double.valueOf(textField_2.getText()), textField_3.getText());
                  products.add(prouct);
                  String id = textField.getText();
                  String Name =  textField_1.getText();
                  String Quality = textField_2.getText();
                  String Cost = textField_3.getText();
                  populateTable();
              try {
                  FileWriter Writer = new FileWriter(&quot;Product.txt&quot;, true);
                  Writer.write(&quot;&quot;+id+&quot;&quot;+Name+&quot;&quot;+Quality+&quot;&quot;+Cost);
                  Writer.write(System.getProperty(&quot;line.separator&quot;));
                  Writer.close();
                  JOptionPane.showMessageDialog(null, &quot;success&quot;);
              }
              catch(Exception r) {
                  JOptionPane.showMessageDialog(null, &quot;Error&quot;);
              }
              }
          });
  
  //Delete Button
  JButton btnNewButton_7 = new JButton(&quot;Delete&quot;);
          btnNewButton_7.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  int i = table.getSelectedRow();
                  tableModel.removeRow(i);
              }
          });
          btnNewButton_7.setBounds(10, 405, 114, 23);
          contentPane.add(btnNewButton_7);
  </code></pre>
  <p>What additional code do I need to add to make the delete button to have the ability of reading the .txt file and make the necessary adjustments?</p>