title: How can I get a dynamic display of my jTable content
body: <p>I would like to display my jTable dynamically in function of my jComboBox selected item.</p>
  <p>By default, my jTable is completed by an ArrayList (completed with a database SELECT) and there is no problem.</p>
  <p>But when I switch my jComoboBox selection to &quot;Tour 2&quot;, I would like my jTable to be updated with new rows completed by another request to the database, for example listeMatch = <code>objMatch.getAllMatch(2,2);</code> instead of <code>listeMatch = objMatch.getAllMatch(2,1);</code> .</p>
  <p>How can I do this please ?</p>
  <pre><code>
  import couche.donnees.MatchDAO;
  import couche.metier.Match;
  
  import javax.swing.*;
  import javax.swing.table.DefaultTableModel;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.ArrayList;
  
  public class FrameArbreSimple extends JFrame {
  
      public ArrayList&lt;Match&gt; listeMatch = new ArrayList&lt;&gt;();
      public MatchDAO objMatch = new MatchDAO();
  
      public String[] columnNames = {
          &quot;ID&quot;, &quot;Joueur 1&quot;, &quot;Joueur 2&quot;, &quot;Tournoi&quot;, &quot;Court&quot;, &quot;Score J1&quot;, &quot;Score J2&quot;, &quot;Date&quot;, &quot;Heure&quot;
      };
  
      public DefaultTableModel model = new DefaultTableModel(){
          public boolean isCellEditable(int row, int column){
              return false;
          }
      };
  
      public FrameArbreSimple() {
          initComponents();
      }
  
      @SuppressWarnings(&quot;unchecked&quot;)
      private void initComponents() {
  
          jPanel1 = new javax.swing.JPanel();
          jComboBox1 = new javax.swing.JComboBox&lt;&gt;();
          jLabel1 = new javax.swing.JLabel();
          jScrollPane1 = new javax.swing.JScrollPane();
          jTable1 = new javax.swing.JTable();
  
          model.setColumnIdentifiers(columnNames);
  
          try {
              listeMatch = objMatch.getAllMatch(2,1);
          } catch (Exception e) {
              System.out.println(e.getMessage());
          }
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
          jPanel1.setLayout(null);
  
          jComboBox1.setModel(new javax.swing.DefaultComboBoxModel&lt;&gt;(new String[] { &quot;Tour 1&quot;, &quot;Tour 2&quot;, &quot;Tour 3&quot;, &quot;Tour 4&quot;, &quot;Tour 5&quot; }));
          jPanel1.add(jComboBox1);
          jComboBox1.setBounds(720, 110, 130, 40);
          jComboBox1.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  if (jComboBox1.getSelectedItem().toString().equals(&quot;Tour 1&quot;)){
                      try {
                          listeMatch = objMatch.getAllMatch(2,1);
                      } catch (Exception e) {
                          System.out.println(e.getMessage());
                      }
                  } else if (jComboBox1.getSelectedItem().toString().equals(&quot;Tour 2&quot;)){
                      try {
                          listeMatch = objMatch.getAllMatch(2,2);
                      } catch (Exception e) {
                          System.out.println(e.getMessage());
                      }
                  }
              }
          });
  
          Object[] o = new Object[9];
          for (Match match : listeMatch) {
              o[0] = match.getIdmatch();
              o[1] = match.getIdequipe1();
              o[2] = match.getIdequipe2();
              o[3] = match.getIdtournoi();
              o[4] = match.getIdcourt();
              o[5] = match.getScore1();
              o[6] = match.getScore2();
              o[7] = match.getDate();
              o[8] = match.getHeure();
              model.addRow(o);
          }
  
          jLabel1.setFont(new java.awt.Font(&quot;Segoe UI&quot;, 0, 24)); // NOI18N
          jLabel1.setText(&quot;Arborescence du tournoi&quot;);
          jPanel1.add(jLabel1);
          jLabel1.setBounds(320, 30, 340, 70);
  
          jTable1.setModel(model);
          jScrollPane1.setViewportView(jTable1);
  
          jPanel1.add(jScrollPane1);
          jScrollPane1.setBounds(40, 170, 810, 400);
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                          .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          );
          layout.setVerticalGroup(
                  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                          .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          );
  
          pack();
      }
  
      private javax.swing.JComboBox&lt;String&gt; jComboBox1;
      private javax.swing.JLabel jLabel1;
      private javax.swing.JPanel jPanel1;
      private javax.swing.JScrollPane jScrollPane1;
      private javax.swing.JTable jTable1;
  
  }
  </code></pre>