aspose file tools*
The moose likes JDBC and the fly likes update a row in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "update a row in JTable" Watch "update a row in JTable" New topic
Author

update a row in JTable

nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
Hello,

I have a prob,after runnig my code i find that a row row added to my DataBase,not the selected row updatting!!!
Please I need help!!

You can find here my code:

public void modifier(JTable tableau,String CH1,String CH2,String CH3,String CH4){

int lign= tableau.getSelectedRow();


try {
Statement stmt = C.createStatement();

stmt.executeUpdate("Update Compte Set NomCompte='"+CH1+"', SoldeInitial='"+CH2+"', Date='"+CH3+"', Description='"+CH4+"' Where Indice="+lign);

System.out.println("********************");
//tableau.removeRowSelectionInterval(lign, lign);
tableau.revalidate();
}
catch (SQLException ex) {

System.out.println("Erreur de suppression du compte.");
ex.printStackTrace();
JOptionPane.showMessageDialog(null,ex.getMessage());
}
}
}



private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
Nouveau_compte N1=new Nouveau_compte();
N1.remplissage(recupererch1(),recupererch2(),recupererch3(),recupererch4());
N1.setVisible(true);
ConnPorCreationCompte C1= new ConnPorCreationCompte();
C1.modifier(jTable2, recupererch1(),recupererch2(),recupererch3(),recupererch4());

// TODO add your handling code here:
}


Please I need help!!!
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Please paste your code inside code tags, it becomes easier to read.


Swastik
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
ok

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package InterfaceSecondaire;

import java.awt.BorderLayout;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import conn.Connexion;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import Conn.ConnPorCreationCompte;
import javax.swing.JTable;
//import Conn.ConnListeCompte;
/**
*
* @author Nadia
*/
public class ListeDesComptes extends javax.swing.JFrame {

/**
* Creates new form ListeDesComptes
*/

public ListeDesComptes() {
initComponents();
}

String ch1;
String ch2;
String ch3;
String ch4;


/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

PFEPUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("PFEPU").createEntityManager();
compteQuery = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery.getResultList();
compteQuery1 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery1.getResultList();
compteQuery2 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList2 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery2.getResultList();
compteQuery3 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList3 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery3.getResultList();
compteQuery4 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList4 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery4.getResultList();
compteQuery5 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList5 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery5.getResultList();
compteQuery6 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList6 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery6.getResultList();
compteQuery7 = java.beans.Beans.isDesignTime() ? null : PFEPUEntityManager.createQuery("SELECT c FROM Compte c");
compteList7 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : compteQuery7.getResultList();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel13 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTable2 = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton1.setIcon(new javax.swing.ImageIcon("C:\\Users\\Nadia\\Desktop\\Image\\ajouter1.png")); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Nadia\\Desktop\\Image\\moin.png")); // NOI18N
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jButton3.setIcon(new javax.swing.ImageIcon("C:\\Users\\Nadia\\Desktop\\Image\\modifier.png")); // NOI18N
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});

jLabel13.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N
jLabel13.setForeground(new java.awt.Color(0, 51, 204));
jLabel13.setText("Liste des Comptes");

jButton4.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jButton4.setText("Refresh");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});

jTable2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, compteList7, jTable2);
org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nomCompte}"));
columnBinding.setColumnName("Nom Compte");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${soldeInitial}"));
columnBinding.setColumnName("Solde Initial");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${date}"));
columnBinding.setColumnName("Date");
columnBinding.setColumnClass(String.class);
columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${description}"));
columnBinding.setColumnName("Description");
columnBinding.setColumnClass(String.class);
bindingGroup.addBinding(jTableBinding);
jTableBinding.bind();
jScrollPane2.setViewportView(jTable2);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4))
.addGap(29, 29, 29))
.addGroup(layout.createSequentialGroup()
.addGap(198, 198, 198)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(260, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jButton1)
.addGap(18, 18, 18)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 96, Short.MAX_VALUE)
.addComponent(jButton4)
.addGap(44, 44, 44))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
);

bindingGroup.bind();

pack();
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Nouveau_compte No=new Nouveau_compte();
No.setVisible(true);
this.repaint();

// TODO add your handling code here:
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
ListeDesComptes N=new ListeDesComptes();
N.setVisible(true);
N.repaint();



// TODO add your handling code here:
}

//int num;
//int vect []=jTable2.getSelectedRows();
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
ConnPorCreationCompte C = new ConnPorCreationCompte();

C.supprimerCompte(jTable2);
jTable2.revalidate();


repaint();
}

private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {

/*ConnPorCreationCompte C = new ConnPorCreationCompte();
C.supprimerCompte(jTable2);
this.revalidate();*/
// TODO add your handling code here:
}

public String recupererch1()
{
/* int ligne = jTable2.getSelectedRow();//Si tu veut la cellule selectionnée, sinon une autre valeur
int colonne = jTable2.getSelectedColumn();//Si tu veut la cellule selectionnée, sinon une autre valeur
Object c = jTable2.getValueAt(ligne,colonne);
// String A=c.toString();*/

ch1=jTable2.getValueAt(jTable2.getSelectedRow(),0).toString();//pour la 1ere colone
return ch1;
}

public String recupererch2()
{ ch2=jTable2.getValueAt(jTable2.getSelectedRow(),1).toString();//pour la 1ere colone
return ch2;
}
public String recupererch3()
{ ch3=jTable2.getValueAt(jTable2.getSelectedRow(),2).toString();//pour la 1ere colone
return ch3;
}

public String recupererch4()
{ ch4=jTable2.getValueAt(jTable2.getSelectedRow(),3).toString();//pour la 1ere colone
return ch4;
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
/*Nouveau_compte N1=new Nouveau_compte();
N1.remplissage(recupererch1(),recupererch2(),recupererch3(),recupererch4());
N1.setVisible(true);
ConnPorCreationCompte C1= new ConnPorCreationCompte();
C1.modifier(recupererch1(),recupererch2(),recupererch3(),recupererch4());
*/
ModifierCompte M=new ModifierCompte();
M.remplissage(recupererch1(),recupererch2(),recupererch3(),recupererch4());
M.setVisible(true); // TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ListeDesComptes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ListeDesComptes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ListeDesComptes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ListeDesComptes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ListeDesComptes().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.persistence.EntityManager PFEPUEntityManager;
private java.util.List<InterfaceSecondaire.Compte> compteList;
private java.util.List<InterfaceSecondaire.Compte> compteList1;
private java.util.List<InterfaceSecondaire.Compte> compteList2;
private java.util.List<InterfaceSecondaire.Compte> compteList3;
private java.util.List<InterfaceSecondaire.Compte> compteList4;
private java.util.List<InterfaceSecondaire.Compte> compteList5;
private java.util.List<InterfaceSecondaire.Compte> compteList6;
private java.util.List<InterfaceSecondaire.Compte> compteList7;
private javax.persistence.Query compteQuery;
private javax.persistence.Query compteQuery1;
private javax.persistence.Query compteQuery2;
private javax.persistence.Query compteQuery3;
private javax.persistence.Query compteQuery4;
private javax.persistence.Query compteQuery5;
private javax.persistence.Query compteQuery6;
private javax.persistence.Query compteQuery7;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel13;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTable jTable2;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration
}
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package InterfaceSecondaire;
import Conn.ConnPorCreationCompte;
import javax.swing.JTable;
/**
*
* @author Nadia
*/
public class ModifierCompte extends javax.swing.JFrame {

/**
* Creates new form ModifierCompte
*/
public ModifierCompte() {
initComponents();
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
Date = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
Nom = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
Description = new javax.swing.JTextArea();
jLabel6 = new javax.swing.JLabel();
Solde = new javax.swing.JTextField();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel4.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jLabel4.setText("Date de création :");

jLabel5.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 0, 0));
jLabel5.setText("Veuillez paramétrer la monnaie utilisée");

jLabel13.setFont(new java.awt.Font("Tahoma", 3, 24)); // NOI18N
jLabel13.setForeground(new java.awt.Color(0, 51, 204));
jLabel13.setText("Modifier Compte");

jButton2.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jButton2.setText("Initialiser");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel1.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jLabel1.setText("Nom du compte :");

jLabel2.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jLabel2.setText("Solde initial du compte :");

Date.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DateActionPerformed(evt);
}
});

jLabel3.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jLabel3.setText("Description du compte :");

jButton1.setFont(new java.awt.Font("Tahoma", 3, 12)); // NOI18N
jButton1.setText("Enregistrer");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

Description.setColumns(20);
Description.setRows(5);
jScrollPane1.setViewportView(Description);

jLabel6.setText("JJ/MM/AAAA");

Solde.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SoldeActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(159, 159, 159)
.addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(64, 64, 64)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Solde, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(36, 36, 36)
.addComponent(Date))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(Nom)))))
.addGap(19, 19, 19))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addComponent(jLabel6)))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addGap(22, 22, 22))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(jLabel13)
.addGap(47, 47, 47)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(Nom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(Solde, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(Date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

Nom.setText(null);
Solde.setText(null);
Date.setText(null);
Description.setText(null);

// TODO add your handling code here:
}

private void DateActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

public void remplissage(String CH1,String CH2,String CH3,String CH4){

Nom.setText(CH1);
Solde.setText(CH2);
Date.setText(CH3);
Description.setText(CH4);

}


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

ConnPorCreationCompte conn1=new ConnPorCreationCompte();
/*String NomCompte=Nom.getText();
String Solde1=Solde.getText();
String Date1=Date.getText();
String Description1=Description.getText();*/
ListeDesComptes L=new ListeDesComptes();
ConnPorCreationCompte C1= new ConnPorCreationCompte();
C1.modifier(L.recupererch1(),L.recupererch2(),L.recupererch3(),L.recupererch4());
// TODO add your handling code here:
}

private void SoldeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ModifierCompte.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ModifierCompte.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ModifierCompte.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ModifierCompte.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ModifierCompte().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField Date;
private javax.swing.JTextArea Description;
private javax.swing.JTextField Nom;
private javax.swing.JTextField Solde;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
}
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
After runnig I found this exception :
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1

I don't understand
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:371)
at java.util.ArrayList.get(ArrayList.java:384)
at org.jdesktop.swingbinding.impl.ListBindingManager$ColumnDescriptionManager.validateBinding(ListBindingManager.java:191)
at org.jdesktop.swingbinding.impl.ListBindingManager.valueAt(ListBindingManager.java:99)
at org.jdesktop.swingbinding.JTableBinding$BindingTableModel.getValueAt(JTableBinding.java:713)
at javax.swing.JTable.getValueAt(JTable.java:2716)
at InterfaceSecondaire.ListeDesComptes.recupererch1(ListeDesComptes.java:228)
at InterfaceSecondaire.ModifierCompte.jButton1ActionPerformed(ModifierCompte.java:216)
at InterfaceSecondaire.ModifierCompte.access$200(ModifierCompte.java:12)
at InterfaceSecondaire.ModifierCompte$3.actionPerformed(ModifierCompte.java:85)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:702)
at java.awt.EventQueue$4.run(EventQueue.java:700)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Its still not within code tags, I have edited this for you.


Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Print the complete stack trace and try to find out which line is raising that exception.
nadia ghezaiel
Ranch Hand

Joined: Apr 13, 2013
Posts: 40
Think Swastik

But I can't see where is the modification???Where is the pb and then the solution??
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Did you notice my last post. You said its showing an exception, I said pint the complete exception stack trace and see from where its causing the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update a row in JTable
 
Similar Threads
synchronized
deleting row from jTable
JTable ........
jtable
how to manage values of disabled cells in a row to the actionServlet in a loop?