158 lines
7.0 KiB
Java
158 lines
7.0 KiB
Java
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
|
|
*/
|
|
package presentation;
|
|
|
|
import Metier.Medicament;
|
|
import acces_aux_donnes.MedicamentSQL;
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
*
|
|
* @author emile.lalorcey
|
|
*/
|
|
public class jffFamilleMedoc extends javax.swing.JFrame {
|
|
|
|
/**
|
|
* Creates new form jffFamilleMedoc
|
|
*/
|
|
public jffFamilleMedoc() {
|
|
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">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
jLabel1 = new javax.swing.JLabel();
|
|
jLRecherche = new javax.swing.JLabel();
|
|
jTFRecherche = new javax.swing.JTextField();
|
|
jBRechercheValide = new javax.swing.JButton();
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
|
|
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/logodetoure.gif"))); // NOI18N
|
|
|
|
jLRecherche.setText("Recherche médicament : ");
|
|
|
|
jTFRecherche.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jTFRechercheActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
jBRechercheValide.setText("Rechercher");
|
|
jBRechercheValide.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
jBRechercheValideActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
getContentPane().setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
.addContainerGap(344, Short.MAX_VALUE)
|
|
.addComponent(jLabel1)
|
|
.addContainerGap())
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addGap(20, 20, 20)
|
|
.addComponent(jLRecherche)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
.addComponent(jTFRecherche, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
.addComponent(jBRechercheValide)
|
|
.addGap(27, 27, 27))
|
|
);
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addComponent(jLabel1)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(jLRecherche)
|
|
.addComponent(jTFRecherche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addComponent(jBRechercheValide))
|
|
.addContainerGap(227, Short.MAX_VALUE))
|
|
);
|
|
|
|
pack();
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void jTFRechercheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFRechercheActionPerformed
|
|
|
|
}//GEN-LAST:event_jTFRechercheActionPerformed
|
|
|
|
private void jBRechercheValideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBRechercheValideActionPerformed
|
|
String medocRechercher = jTFRecherche.getText();
|
|
MedicamentSQL medocTest = new MedicamentSQL();
|
|
ArrayList<String> rechercheMedoc = new ArrayList<String>();
|
|
rechercheMedoc = medocTest.rechercherMedicament(medocRechercher);
|
|
if (rechercheMedoc.get(0) != null) {
|
|
String idTrouve = rechercheMedoc.get(0);
|
|
String nomTrouve = rechercheMedoc.get(1);
|
|
String compositionTrouve = rechercheMedoc.get(2);
|
|
String effetTrouve = rechercheMedoc.get(3);
|
|
String contreIndicationTrouve = rechercheMedoc.get(4);
|
|
String imgTrouve = "../img/"+ idTrouve +".jpg";
|
|
Medicament medocTrouve = new Medicament(idTrouve, nomTrouve , compositionTrouve, effetTrouve
|
|
, contreIndicationTrouve,imgTrouve);
|
|
new jffInfoMedoc(medocTrouve).setVisible(true);
|
|
|
|
|
|
}else {
|
|
//ajout d'un JoptionPane
|
|
}
|
|
}//GEN-LAST:event_jBRechercheValideActionPerformed
|
|
|
|
/**
|
|
* @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(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
} catch (InstantiationException ex) {
|
|
java.util.logging.Logger.getLogger(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
} catch (IllegalAccessException ex) {
|
|
java.util.logging.Logger.getLogger(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
|
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
|
java.util.logging.Logger.getLogger(jffFamilleMedoc.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 jffFamilleMedoc().setVisible(true);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JButton jBRechercheValide;
|
|
private javax.swing.JLabel jLRecherche;
|
|
private javax.swing.JLabel jLabel1;
|
|
private javax.swing.JTextField jTFRecherche;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|