title: problem when implementing a selection listener in a JTable
body: <p>I am developing a JTable with different rows. I would like to associate an event to the selection of a row in this table. I have used the following selection class to provide behaviour to the table selection:</p>
  
  <pre><code>public class TableSelectionListener implements ListSelectionListener{
  
  public Integer item;    
  
  public TableSelectionListener(Integer item){
      this.dialog = item;
  }
  
  public void valueChanged(ListSelectionEvent e) {
  
      System.out.println("The row clicked is "+item);
  
      }
  }
  </code></pre>
  
  <p>When I create an instance of this table, sai <em>tabletest</em>, I have added the following piece of code:</p>
  
  <pre><code>tabletest.getSelectionModel().addListSelectionListener(new TableSelectionListener(tabletest.getSelectedRow());
  </code></pre>
  
  <p>The problem is that when I click on one row once, instead of retrieving the related message once, I retrieve the same message several times, suggesting that the actions repeated several times. For example:</p>
  
  <pre><code>The row clicked is 0
  The row clicked is 0
  The row clicked is 0
  The row clicked is 0
  </code></pre>
  
  <p>Does anyone know where the problem may be?</p>