Note that there are some explanatory texts on larger screens.

plurals
  1. POJava swing jTable not being updated
    text
    copied!<p>I built a jTable using NetBeans GUI, and I want to update it inside the constructor of the class. I'm planning to add a search option on the frame so the whole update idea is quite critical for me.</p> <p>My code:</p> <pre><code> public availableTrumps(TrumpistClient TC){ initComponents(); availableTrumpsTrumpistClient=TC; String result=null; String query="SELECT * FROM APP.TRUMPS"; result=this.availableTrumpsTrumpistClient.WritingReading("sql_select", query); if (result.contains("empty")){ JOptionPane.showMessageDialog(this, "There are now trumps to show."); } else if (result.contains("error")){ JOptionPane.showMessageDialog(this, "Error in the connection. Please try again."); } else{ int i; String []data = result.split("\r\n"); String [][] data2 = new String [data.length][]; for (i = 0; i &lt; data.length; i++) { data2[i] = data[i].split("&amp;"); } String[] columnNames = {"From", "To", "Departure Time", "Remaining Places", "Proposer", "ClosingTime", "Cost Per Seat" }; this.jTable1 = new JTable(data2,columnNames); this.jTable1.setPreferredScrollableViewportSize(new Dimension(500,100)); this.jTable1.setFillsViewportHeight(true); JScrollPane jps = new JScrollPane(jTable1); add(jps); jTable1.revalidate(); } } </code></pre> <p>The input two-dimentional array data2 is fine and validated. I added the last 5 rows of the code to see if they help with something. I don't know if they are mandatory and in any case I do not want to change the graphical properties of the jTable I built with the GUI (just the data in it). When I run the program, I see that the jTable remains empty. Why?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload