Bonjour à tous, voilà, j'ai un petit problème. Je fais une recherche sur des fournisseurs. J'aiffiche cette recherche dans une fenetre. Je peux alors modifier les informations de ce fournisseurs et les modifier. Lorsque je clique sur le bouton modifier, une boite de dialogue s'ouvre dans laquelle je choisis de valider ou non ces modifications. Ensuite je reviens sur ma liste de fornisseur. Tout se passe bien sauf que lorsque clique sur OK ou Annuler une fenetre vide s'ouvre en plus et je ne sais pas pourquoi..... Enfin voici mon code si vous y comprenez quelque chose.... Merci d'avance
Code du bouton modifier
btmodiffour.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
//System.out.println(four.getSelectedValue());
Connection con ;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@10.66.66.18:1521:info","admin","admin");
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery("Select four_id from fournisseur where four_nom ='"+four.getSelectedValue()+"'");
rset.next();
new bdmodif(rset.getString(1),fournom.getText(),fouradr.getText(),fourcp.getText(),fourville.getText(),fourtel.getText(),fourfax.getText(),contactnom.getText(),contactprenom.getText(),contacttel.getText(),contactfax.getText()).show();
}
catch(SQLException e1){
System.out.println("SQLException"+e1);
}
catch(Exception e2){
System.out.println("Exception"+e2);
}
setVisible(false);
}
});
Code de la boite de dialogue :
public class bdmodif extends JDialog{
Frame getFrame() {
Component component = this;
do {
component = component.getParent();
} while (!(component instanceof Frame));
return (Frame) component;
}
bdmodif(String id,String nom,String adr,String cp,String ville,String tel,String fax,String cnom,String cprenom,String ctel,String cfax) {
JOptionPane bd = new JOptionPane();
int retour = JOptionPane.showConfirmDialog(getFrame(),
"Confirmer les changements ?", "Confirmation",
JOptionPane.OK_CANCEL_OPTION);
if (retour == JOptionPane.OK_OPTION) {
//System.out.println(this.g_num+this.g_nom +this.g_prenom);
try {
Connection con;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@10.66.66.18:1521:info", "admin","admin");
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery("Update fournisseur set four_nom='"+nom+"',four_adr='"+adr+"',four_cp="+cp+ ",four_ville='"+ville+"',four_tel='"+tel+"',four_fax='"+fax+"',four_contactnom='"+cnom+"',four_contactprenom='"+cprenom+"',four_contacttel='"+ctel+"',four_contactfax='"+cfax+"' where four_id='"+id+"' ");
con.close();
}
catch (SQLException e1) {
System.out.println("SQLException" + e1);
}
catch (Exception e2) {
System.out.println("Exception" + e2);
}
new RechercheFour().show();
}
else{
System.out.println("else");
new RechercheFour().show();
}
}
}
Merci d'avance !!!!