title: Strange java.lang.ClassCastException error
body: <p>I use Java and Netbeans 7.2 
  This is a simple JFrame form. It connects to SQLite database, retrieves all records from one table and puts it into JTable widget (Table1). It works fine.</p>
  
  <p>However, I added 4 text fields that are supposed to be filled with values of a row that has been clicked on in the JTable.</p>
  
  <p>When the click handler starts it inserts just the first column value in the first text field and then the error message pops up saying (java.lang.ClassCastException).</p>
  
  <p>I just can not figure out which row is the problem. Debugger prints error about "uncompilable code" (I dont know how to use debugger).</p>
  
  <pre><code>private void Table1MouseClicked(java.awt.event.MouseEvent evt)      {                                    
  
      try{
          int row = Table1.getSelectedRow();
          String rowId = (Table1.getModel().getValueAt(row, 0).toString());
          String sql = "select * from ljudi where ID='"+rowId+"';";
          pst = conn.prepareStatement(sql);
          rst = pst.executeQuery();
  
          if(rst.next()){
  
              String name = rst.getString("ime");
              String surname = rst.getString("prezime");
              String address = rst.getString("adresa");
              String telephone = rst.getString("telefon");
  
              txt_ime.setText(name);
              txt_prezime.setText(surname);
              txt_adresa.setText(address);
              txt_telefon.setText(telephone);
          }
      }
      catch(Exception e){
          JOptionPane.showMessageDialog(null,e);
      }
  }  
  </code></pre>
  
  <p>I even commented all code inside the method, the Output window shows error messages as soon as I click on a table row.</p>
  
  <pre><code>run:
  Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException
  at java.lang.Class.cast(Class.java:2990)
  at org.jdesktop.beansbinding.Binding.convertForward(Binding.java:1312)
  at org.jdesktop.beansbinding.Binding.getSourceValueForTarget(Binding.java:844)
  at org.jdesktop.beansbinding.Binding.refreshUnmanaged(Binding.java:1222)
  at org.jdesktop.beansbinding.Binding.refresh(Binding.java:1207)
  at org.jdesktop.beansbinding.AutoBinding.tryRefreshThenSave(AutoBinding.java:162)
  at org.jdesktop.beansbinding.AutoBinding.sourceChangedImpl(AutoBinding.java:227)
  at org.jdesktop.beansbinding.Binding.sourceChanged(Binding.java:1411)
  at org.jdesktop.beansbinding.Binding.access$1200(Binding.java:38)
  at org.jdesktop.beansbinding.Binding$PSL.propertyStateChanged(Binding.java:1618)
  at org.jdesktop.beansbinding.PropertyHelper.firePropertyStateChange(PropertyHelper.java:212)
  at org.jdesktop.beansbinding.ELProperty.notifyListeners(ELProperty.java:688)
  at org.jdesktop.beansbinding.ELProperty.access$800(ELProperty.java:155)
  at org.jdesktop.beansbinding.ELProperty$SourceEntry.processSourceChanged(ELProperty.java:312)
  at org.jdesktop.beansbinding.ELProperty$SourceEntry.sourceChanged(ELProperty.java:326)
  at org.jdesktop.beansbinding.ELProperty$SourceEntry.propertyChange(ELProperty.java:333)
  at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
  at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
  at org.jdesktop.swingbinding.adapters.BeanAdapterBase.firePropertyChange(BeanAdapterBase.java:112)
  at org.jdesktop.swingbinding.adapters.JTableAdapterProvider$Adapter$Handler.tableSelectionChanged(JTableAdapterProvider.java:81)
  at org.jdesktop.swingbinding.adapters.JTableAdapterProvider$Adapter$Handler.valueChanged(JTableAdapterProvider.java:91)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)
  at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)
  at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)
  at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442)
  at javax.swing.JTable.changeSelectionModel(JTable.java:2352)
  at javax.swing.JTable.changeSelection(JTable.java:2421)
  at javax.swing.plaf.basic.BasicTableUI$Handler.adjustSelection(BasicTableUI.java:1085)
  at javax.swing.plaf.basic.BasicTableUI$Handler.mousePressed(BasicTableUI.java:1008)
  at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:263)
  at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:262)
  at java.awt.Component.processMouseEvent(Component.java:6264)
  at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
  at java.awt.Component.processEvent(Component.java:6032)
  at java.awt.Container.processEvent(Container.java:2041)
  at java.awt.Component.dispatchEventImpl(Component.java:4630)
  at java.awt.Container.dispatchEventImpl(Container.java:2099)
  at java.awt.Component.dispatchEvent(Component.java:4460)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
  at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4235)
  at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
  at java.awt.Container.dispatchEventImpl(Container.java:2085)
  at java.awt.Window.dispatchEventImpl(Window.java:2478)
  at java.awt.Component.dispatchEvent(Component.java:4460)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
  at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  BUILD SUCCESSFUL (total time: 8 seconds)
  </code></pre>
  
  <p>Any help is much appreciated.</p>
  
  <p>Thank you</p>
  
  <p>P.S. The full stack trace is here as you asked, I suppose that is it.</p>
  
  <p>P.P.S.
  I solved it in a bit different way:</p>
  
  <pre><code>try 
      {
      int pozicija = jTable1.getSelectedRow();
  
      String rowId = jTable1.getModel().getValueAt(pozicija, 0).toString();
  
      String ime = jTable1.getModel().getValueAt(pozicija,1).toString();
  
      String prezime = jTable1.getModel().getValueAt(pozicija,2).toString();
  
      String adresa = jTable1.getModel().getValueAt(pozicija,3).toString();
  
      String telefon = jTable1.getModel().getValueAt(pozicija,4).toString();
  
  
      jTextField1.setText(ime);
      jTextField2.setText(prezime);
      jTextField3.setText(adresa);
      jTextField4.setText(telefon);
      jLabel2.setText(rowId);
      }
      catch(Exception e)
      {
          JOptionPane.showMessageDialog(null, e);
      }
  </code></pre>
  
  <p>Instead of running a query on a database, I used the same field values from jTable model. Works fine and the purpose of this is to populate text fields for editing the record. </p>
  
  <p>I don't think it would be necessary to query the db again?</p>
  
  <p>Btw. I saw the first example on a youtube tutorial by "ProgrammingKnowledge". It has many basic stuff explained.</p>
  
  <p>Thank you for the ideas.</p>