title: JTable TableModel problem in Java
body: <p>I can show my data in a <code>JTable</code> without a problem, but when I want to filter while my app is running, the <code>JTable</code> is not showing me data changes. I searched for it and found a class named TableModel but I can't write my AbstractTableModel. Can anyone show me how I can do this?</p>
  
  <p>Personelz.Java</p>
  
  <pre><code>package deneme.persistence;
  
  import java.beans.PropertyChangeListener;
  import java.beans.PropertyChangeSupport;
  import java.io.Serializable;
  import javax.persistence.Basic;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.NamedQueries;
  import javax.persistence.NamedQuery;
  import javax.persistence.Table;
  import javax.persistence.Transient;
  
  /**
   *
   * @author İbrahim AKGÜN
   */
  @Entity
  @Table(name = "PERSONELZ", catalog = "tksDB", schema = "dbo")
  @NamedQueries({@NamedQuery(name = "Personelz.findAll", query = "SELECT p FROM Personelz p"), @NamedQuery(name = "Personelz.findByPersonelıd", query = "SELECT p FROM Personelz p WHERE p.personelıd = :personelıd"), @NamedQuery(name = "Personelz.findByAd", query = "SELECT p FROM Personelz p WHERE p.ad = :ad"), @NamedQuery(name = "Personelz.findBySoyad", query = "SELECT p FROM Personelz p WHERE p.soyad = :soyad")})
  public class Personelz implements Serializable {
      @Transient
      private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Basic(optional = false)
      @Column(name = "PERSONELID", nullable = false )
      private Integer personelıd;
      @Column(name = "AD", length = 50)
      private String ad;
      @Column(name = "SOYAD", length = 50)
      private String soyad;
      @Column(name = "YAS")
      private Integer yas;
      public Personelz() {
      }
  
      public Personelz(Integer personelıd) {
          this.personelıd = personelıd;
      }
  
      public Integer getPersonelıd() {
          return personelıd;
      }
  
      public void setPersonelıd(Integer personelıd) {
          this.personelıd = personelıd;
      }
  
      public String getAd() {
          return ad;
      }
  
      public void setAd(String ad) {
          String oldAd = this.ad;
          this.ad = ad;
          changeSupport.firePropertyChange("ad", oldAd, ad);
      }
  
      public String getSoyad() {
          return soyad;
      }
  
      public void setSoyad(String soyad) {
          String oldSoyad = this.soyad;
          this.soyad = soyad;
          changeSupport.firePropertyChange("soyad", oldSoyad, soyad);
      }
       public Integer getYas() {
          return yas;
      }
  public void setYas(Integer yas){
  this.yas = yas;
  
  }
  </code></pre>
  
  <p>TABLEMODEL </p>
  
  <pre><code> public class TableModel extends AbstractTableModel {
  
  String[] headers;
  List&lt;Personelz&gt; personel;
  int row;
  int column;
  Object[][] per;
  /** Creates a new instance of TableModel */
      @SuppressWarnings("empty-statement")
  public TableModel(List&lt;Personelz&gt; p) {
  
      this.personel = p;
      column=2;
      row=this.personel.size();
  
      headers=new String[column];
      headers[0]="AD";
      headers[1]="SOYAD";
      per={p.toArray(),p.toArray()};
  
  }
  
   public int getColumnCount()
   {
       return column;
   }
   public int getRowCount()
   {
       return row;
   }
   public Object getValueAt(int rowIndex, int kolonindex)
   {
  
       return per[rowIndex][kolonindex];
   }
   public String getColumnName(int i)
   {
       return headers[i];
   }
  </code></pre>