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
}