title: how to make my JTable refresh after adding a new row
body: <p>After I add a new row to a <code>JTable</code>. The information wrote goes to the txt file, but my <code>JTable</code> doesn't shows the last raw. But if I close the program, and run it again, the information it's in the table. So, is there a way to refresh the data in the <code>JTable</code> without closing the application and running it again?</p>
  
  <pre><code>String[] columns = {"nume", "compozitie", "indicatii", "contraindicatii", "administrare", "pret", "compensabil", "stoc"};
  
  Object[][] data = null;
  try {
      File file = new File("medicamente.txt");
      FileReader fileReader = new FileReader(file);
      BufferedReader bufferedReader = new BufferedReader(fileReader);
      data = new Object[100][];
      String line;
      int numLines = 0;
      while ((line = bufferedReader.readLine()) != null) {
          data[numLines] = line.split(",");
          numLines++;
      }
  
      fileReader.close();
  
  } catch (IOException e) {
      e.printStackTrace();
  }
  
  TableModel model = new DefaultTableModel(data, columns) {
      @Override
      public Class getColumnClass(int column) {
          Class returnValue;
          if ((column &gt;= 0) &amp;&amp; (column &lt; getColumnCount())) {
              returnValue = getValueAt(0, column).getClass();
          } else {
              returnValue = Object.class;
          }
          return returnValue;
      }
  };
  
  JTable table = new JTable(model) {
      public boolean isCellEditable(int row, int column) {
          return false;
      }
  };
  
  final TableRowSorter&lt;TableModel&gt; sorter = new TableRowSorter&lt;TableModel&gt;(model);
  table.setRowSorter(sorter);
  JScrollPane scrollPane = new JScrollPane(table);
  scrollPane.setPreferredSize(new Dimension(1000, 500));
  mainPanel.add(scrollPane);
  scrollPane.setBounds(0, 240, 995, 510);
  
  final JTextField filterText = new JTextField(null);
  mainPanel.add(filterText);
  filterText.setBounds(0, 750, 850, 25);
  
  JButton button = new JButton("Filter");
  mainPanel.add(button);
  button.setBounds(850, 750, 150, 25);
  button.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
          String text = filterText.getText();
          if (text.length() == 0) {
              sorter.setRowFilter(null);
              //   model.fireTableDataChanged();                       
  
          } else {
              sorter.setRowFilter(RowFilter.regexFilter(text));
          }
      }
  });
  </code></pre>