title: Why Jtable Does not refresh from other class
body: <p>I have the following cod!
  when i call the fruitsTable() from refreshButton() it refreshes the JTable! but when i call it from another class it does not refresh the Table! bellow is the simplified code</p>
  
  <pre><code>public ResultSet sqlCommand(String sqlStatement) throws SQLException
  
      {
          this.sqlStatement = sqlStatement;
          ConnectingToMysql fruitsConnection = new ConnectingToMysql();
          Connection myConnection = fruitsConnection.ConnectingToMysql();
          Statement st = myConnection.createStatement();
          ResultSet result = st.executeQuery(sqlStatement);
          return result;          
      }       
  
      public Vector&lt;String&gt; getColumnData() throws SQLException
      {
          ResultSetMetaData metaData = sqlCommand(sqlStatement).getMetaData();
          int columnCount = metaData.getColumnCount();
          Vector&lt;String&gt; allColumn = new Vector&lt;String&gt;();                    
          for(int i = 1; i &lt;= columnCount; i++)
          {
              allColumn.add(metaData.getColumnName(i));
          }           
          return allColumn;
      }       
  
      public Vector&lt;Vector&lt;String&gt;&gt; getData() throws SQLException
      {
          ResultSet result = sqlCommand(sqlStatement);
          ResultSetMetaData metaData = result.getMetaData();
          int columnCount = metaData.getColumnCount();            
          Vector&lt;Vector&lt;String&gt;&gt; allRow = new Vector&lt;Vector&lt;String&gt;&gt;(columnCount);            
          while(result.next())
          {
              Vector&lt;String&gt; eachRow = new Vector&lt;String&gt;();
              for(int i = 1; i &lt;= columnCount; i++)
              {
                  eachRow.add(result.getString(i));
              }
              allRow.add(eachRow);
          }               
          return allRow;              
      }
  
      public JScrollPane fruitsTable() throws SQLException
      {
          Vector&lt;String&gt; columnData = getColumnData();
          Vector&lt;Vector&lt;String&gt;&gt; rowData = getData();
          fruitsTableModel.setDataVector(rowData,columnData);         
          Font font = new Font("Courier", Font.PLAIN,16);             
          fruitsTable = new JTable();         
          fruitsTable.setModel(fruitsTableModel);                 
          fruitsTable.setPreferredScrollableViewportSize(new Dimension(850,310));
          fruitsTable.setRowHeight(30);
          fruitsTable.setFont(font);
          JScrollPane fruitsScrollPane = new JScrollPane(fruitsTable);            
          dataValue();            
          return fruitsScrollPane;            
      }
  
      private JButton refreshButton() throws SQLException
      {
          JButton refreshButton = new JButton("Refresh Record");
          refreshButton.setPreferredSize(new Dimension(100,40));          
          refreshButton.addActionListener(new ActionListener()
          {
              public void actionPerformed(ActionEvent e)
              {
                  try 
                  {
                      fruitsTable();                      
                  } catch (SQLException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                  }    
              }                   
          });
          return refreshButton;           
      }
  </code></pre>
  
  <p>and this is the only code from the other class that calls the fruitsTable().</p>
  
  <pre><code>saveButton.addActionListener(new ActionListener()
      {
          public void actionPerformed(ActionEvent event)
          {           
              try
              {                   
                  String number = numberTextField.getText();
                  int ID = Integer.parseInt(number);
                  String fruit = fruitTextField.getText();
                  String color = colorTextField.getText();
                  String taste = tasteTextField.getText();                    
                  System.out.println("The value is: " + number + " " + fruit + " " + color + " " + taste);
  
                  String sqlText = "Insert into fruits(ID,Fruit,Color,Tast) values(?,?,?,?)";
  
                  ConnectingToMysql connectingToMysql = new ConnectingToMysql();
                  Connection makeConnection = connectingToMysql.ConnectingToMysql();
                  PreparedStatement pdt = makeConnection.prepareStatement(sqlText);       
                  pdt.setInt(1,ID);                       
                  if(fruit.isEmpty())
                  {
                      pdt.setNull(2,java.sql.Types.VARCHAR);
                  }
  
                  else
                  {
                      pdt.setString(2,fruit);
                  }                   
                  if(color.isEmpty())
                  {
                      pdt.setNull(3,java.sql.Types.VARCHAR);
                  }
                  else
                  {
                      pdt.setString(3,color);
                  }                   
                  if(taste.isEmpty())
                  {
                      pdt.setNull(4,java.sql.Types.VARCHAR);
                  }
                  else
                  {
                      pdt.setString(4,taste);    
                  }                   
                  pdt.executeUpdate();                    
                  GetFruits getFruits = new GetFruits();
                  getFruits.fruitsTable();
              }               
              catch(SQLIntegrityConstraintViolationException e)
              {
                  JOptionPane.showMessageDialog(null, "The 'Number' you entered already exist!", "Error", JOptionPane.ERROR_MESSAGE);
                  System.out.println(e);
              }
  </code></pre>