slt j ai un probleme avec mon application c est en java avec ecplise les champs se place les une a cote des des otres voici le code je voudrais que chaque champs ait sa propre ligne si quelqu' un peux m aider
package dialogue;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.util.Vector;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
//import javax.swing.text.JTextComponent;
import controle.ControleConnnexion;
import controle.GestionDemandeFourn;
public class FenFicheFourniture extends JFrame {
private static final long serialVersionUID = 1L;
private DefaultTableModel leModeleTransmisParFenTAble;
private GestionDemandeFourn leFournitureGestionFournitureBD = new GestionDemandeFourn();
private JPanel jContentPane = null;
private JTextField jTxTcode_four = null;
private JTextField jTxTlibelle_four = null;
private JTextField jTxTquantite = null;
public static JComboBox jTxTnumero_en = null;
public static JComboBox jTxTcode_ty = null;
private JLabel jLabelcode_four = null;
private JLabel jLabellibelle_four= null;
private JLabel jLabelquantite= null;
private JButton btn_Enregistrer = null;
private JButton btn_Quitter = null;
private JButton btn_Supprimer = null;
private JButton btn_Rechercher = null;
private Connection laConnexion=ControleConnnexion.getConnexion();
public FenFicheFourniture(DefaultTableModel leModele) {
super();
initialize();
//setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
leModeleTransmisParFenTAble = leModele;
}
private void initialize() {
this.setSize(579, 344);
this.setContentPane(getJContentPane());
this.setTitle("gestion de stock et approvisionements");
this.setContentPane(getJContentPane());
this.setLocationRelativeTo(null);
this.setResizable(false);
this.setVisible(false);
//jContentPane.setLayout(new GridLayout(12,4));
}
private JPanel getJContentPane() {
if (jContentPane == null) {
JLabel jLabelcode_ty = new JLabel();
jLabelcode_ty.setBounds(new Rectangle(72, 99, 76, 16));
jLabelcode_ty.setText("code_ty");
JLabel jLabelnumero_en = new JLabel();
jLabelnumero_en.setBounds(new Rectangle(72, 77, 78, 16));
jLabelnumero_en.setText("numero_en");;
jLabelquantite = new JLabel();
jLabelquantite.setBounds(new Rectangle(72, 53, 77, 16));
jLabelquantite.setText("quantite");
jLabellibelle_four = new JLabel();
jLabellibelle_four.setBounds(new Rectangle(72, 49, 76, 16));
jLabellibelle_four.setText("libelle_liv");
jLabelcode_four= new JLabel();
jLabelcode_four.setBounds(new Rectangle(72, 40, 100, 16));
jLabelcode_four.setText("code_four");
jContentPane = new JPanel();
//jContentPane.setLayout(null);
jContentPane.setLayout(new GridLayout(5, 4));
jContentPane.add(getJTxTcode_four(), null);
jContentPane.add(getJTxTlibelle_four(), null);
jContentPane.add(getJTxTquantite(), null);
jContentPane.add(getJTxTnumero_en(), null);
jContentPane.add(getJTxTcode_ty(), null);
jContentPane.add(jLabelcode_four, null);
jContentPane.add(jLabellibelle_four, null);
jContentPane.add(jLabelquantite, null);
jContentPane.add(jLabelnumero_en, null);
jContentPane.add(jLabelcode_ty, null);
jContentPane.add(getBtn_Enregistrer(), null);
jContentPane.add(getBtn_Quitter(), null);
jContentPane.add(getBtn_Supprimer(), null);
jContentPane.add(getBtn_Rechercher(), null);
}
return jContentPane;
}
public JTextField getJTxTcode_four() {
if (jTxTcode_four == null) {
jTxTcode_four= new JTextField();
jTxTcode_four.setBounds(new Rectangle(151, 51, 125, 20));
}
return jTxTcode_four ;
}
public JTextField getJTxTlibelle_four() {
if (jTxTlibelle_four == null) {
jTxTlibelle_four = new JTextField();
jTxTlibelle_four.setBounds(new Rectangle(152, 75, 124, 20));
}
return jTxTlibelle_four;
}
public JTextField getJTxTquantite() {
if (jTxTquantite == null) {
jTxTquantite = new JTextField();
jTxTquantite.setBounds(new Rectangle(153, 100, 124, 20));
}
return jTxTquantite;
}
public JComboBox getJTxTnumero_en() {
System.out.println("zerzrezrer");
java.util.Vector <String>v=null;
try{
if (jTxTnumero_en == null) {
try{ String requete = "select numero_en FROM entree";
Statement state = laConnexion.createStatement();
ResultSet rs=state.executeQuery(requete);
v=new java.util.Vector<String>();
while(rs.next()){
v.add(rs.getString(1));
}
}
catch(Exception ze){
System.out.println("Erreur connexion BD "+ze.getMessage());
}
finally{
jTxTnumero_en = new JComboBox(v);
jTxTnumero_en.setBounds(new Rectangle(153, 100, 124, 20));
}
}
return jTxTnumero_en;
}
catch(Exception er){ System.out.println("errr "+er.getMessage());er.printStackTrace();return null;
}
}
public JComboBox getJTxTcode_ty() {
System.out.println("zerzrezrer");
java.util.Vector <String>v=null;
try{
if (jTxTcode_ty == null) {
try{ String requete = "select code_ty FROM type";
Statement state = laConnexion.createStatement();
ResultSet rs=state.executeQuery(requete);
v=new java.util.Vector<String>();
while(rs.next()){
v.add(rs.getString(1));
}
}
catch(Exception ze){
System.out.println("Erreur connexion BD "+ze.getMessage());
}
finally{
jTxTcode_ty = new JComboBox(v);
jTxTcode_ty.setBounds(new Rectangle(153, 100, 124, 20));
}
}
return jTxTcode_ty;
}
catch(Exception er){ System.out.println("errr "+er.getMessage());er.printStackTrace();return null;
}
}
public void setJTxTcode_four(String vcode_four) {
jTxTcode_four.setText(vcode_four) ;
}
public void setJTxTlibelle_four(String vlibelle_four) {
jTxTlibelle_four.setText(vlibelle_four) ;
}
public void setJTxTquantite(String vquantite) {
jTxTquantite.setText(vquantite) ;
}
public void setJTxTnumero_en(String vnumero_en) {
jTxTnumero_en.addItem(vnumero_en) ;
}
public void setJTxTcode_ty(String vcode_ty) {
jTxTcode_ty.addItem(vcode_ty);
}
public void setBtn_EnregistrerLibelle(String vLibelle) {
btn_Enregistrer.setText(vLibelle);
}
private JButton getBtn_Enregistrer() {
if (btn_Enregistrer == null) {
btn_Enregistrer = new JButton();
btn_Enregistrer.setBounds(new Rectangle(19, 237, 126, 41));
btn_Enregistrer.setText("SAUVEGARDER");
btn_Enregistrer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e){
String vcode_four= jTxTcode_four.getText();
String vlibelle_four = jTxTlibelle_four.getText();
String vquantite = jTxTquantite.getText();
String vnumero_en = jTxTnumero_en.getSelectedItem().toString();
String vcode_ty = jTxTcode_ty.getSelectedItem().toString();
if (btn_Enregistrer.getText().equals("SAUVEGARDER")){
if(!vcode_four.equals("")){
boolean bCreation ;
bCreation = leFournitureGestionFournitureBD.demandeEnregistrerFourniture(vcode_four,vlibelle_four ,vquantite,vnumero_en, vcode_ty);
System.out.println("bCreation = "+ bCreation);
if (bCreation == true){
jTxTcode_four.setText("");
jTxTlibelle_four.setText("");
jTxTquantite.setText("");
//jTxTdescriptif.setText("");
jTxTcode_four.requestFocusInWindow();
Vector<String> ligne = new Vector<String>();
leModeleTransmisParFenTAble.addRow(ligne);
int nbLignes = leModeleTransmisParFenTAble.getRowCount();
nbLignes = nbLignes -1;
leModeleTransmisParFenTAble.setValueAt(vcode_four, nbLignes, 0);
leModeleTransmisParFenTAble.setValueAt(vlibelle_four, nbLignes, 1);
leModeleTransmisParFenTAble.setValueAt(vquantite, nbLignes, 2);
leModeleTransmisParFenTAble.setValueAt(vnumero_en, nbLignes, 3);
leModeleTransmisParFenTAble.setValueAt(vcode_ty, nbLignes, 4);
}
}
else {
JOptionPane.showMessageDialog(null, "La saisie du code fourniture "
+ " est obligatoire",
"Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
}
}
else {
boolean bModification ;
bModification = leFournitureGestionFournitureBD.demandeEnregistrerFourniture(vcode_four, vlibelle_four,vquantite, vnumero_en,vcode_ty);
if(bModification == true){
int i = 1;
int ligne = 0;
int colonne = 0;
boolean bTrouve = false;
String lecode_four;
while(i <= leModeleTransmisParFenTAble.getRowCount()&& bTrouve==false){
lecode_four=(String)leModeleTransmisParFenTAble.getValueAt(ligne, colonne);
if(lecode_four.equals(vcode_four)){
bTrouve = true;
leModeleTransmisParFenTAble.setValueAt(vcode_four, ligne, 0);
leModeleTransmisParFenTAble.setValueAt(vlibelle_four, ligne, 1);
leModeleTransmisParFenTAble.setValueAt(vquantite, ligne, 2);
leModeleTransmisParFenTAble.setValueAt(vnumero_en, ligne, 3);
leModeleTransmisParFenTAble.setValueAt(vcode_four, ligne, 4);
}
i++;
ligne++;
}
}
}
}
});
}
return btn_Enregistrer;
}
private JButton getBtn_Supprimer() {
if (btn_Supprimer == null) {
btn_Supprimer = new JButton();
btn_Supprimer.setBounds(new Rectangle(144, 237, 138, 41));
btn_Supprimer.setText("SUPPRIMER");
btn_Supprimer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
String vcode_four = jTxTcode_four.getText();
if(!vcode_four.equals("")){
boolean bSuppression ;
int choix = JOptionPane.showConfirmDialog(null,
"Voulez-vous supprimer la fiche du fourniture code : " + vcode_four + " ?", "Suppression",
JOptionPane.YES_NO_OPTION);
if (choix==0){
bSuppression = leFournitureGestionFournitureBD.demandeSupprimmerFourniture(vcode_four);
if(bSuppression==true)
jTxTcode_four.setText("");
jTxTcode_four.requestFocusInWindow();
int i = 1;
int ligne = 0;
int colonne = 0;
boolean bTrouve = false;
String lecode_four;
while(i <= leModeleTransmisParFenTAble.getRowCount()&& bTrouve==false){
lecode_four=(String)leModeleTransmisParFenTAble.getValueAt(ligne, colonne);
if(lecode_four.equals(vcode_four)){
bTrouve = true;
leModeleTransmisParFenTAble.removeRow(i-1);
}
i++;
ligne++;
}
}
}
else {
JOptionPane.showMessageDialog(null, "La saisie du code fourniture "
+ " est obligatoire",
"Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
}
}
});
}
return btn_Supprimer;
}
private JButton getBtn_Rechercher() {
if (btn_Rechercher == null) {
btn_Rechercher = new JButton();
btn_Rechercher.setBounds(new Rectangle(281, 237, 126, 41));
btn_Rechercher.setText("CHERCHER");
btn_Rechercher.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
String vcode_four = jTxTcode_four.getText();
String vlibelle_four = jTxTlibelle_four.getText();
String vquantite= jTxTquantite.getText();
String vnumero_en = jTxTnumero_en.getSelectedItem().toString();
String vcode_ty= jTxTcode_ty.getSelectedItem().toString();
if(!vcode_four.equals("")|| !vlibelle_four.equals("") || !vquantite.equals("")|| !vnumero_en.equals("")|| !vcode_ty.equals("")){
int nbEnreg = leFournitureGestionFournitureBD.demandeChercherFourniture(vcode_ty);
if(nbEnreg > 0){
switch(nbEnreg)
{
case 0:
JOptionPane.showMessageDialog(null, "Aucune fourniture trouvé."
+ " Ce code fourniture n'existe pas.",
"Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
break;
case 1:
JOptionPane.showMessageDialog(null, nbEnreg + " fourniture trouvé",
"RESULTAT", JOptionPane.INFORMATION_MESSAGE);
break;
default:
JOptionPane.showMessageDialog(null, nbEnreg + " fourniture trouvés.",
"RESULTAT", JOptionPane.INFORMATION_MESSAGE);
}
btn_Enregistrer.setEnabled(true);
jTxTcode_four.setText(vcode_four);
new FenResultatRechercheFourn(vcode_four);
}
if(nbEnreg == 0){
JOptionPane.showMessageDialog(null, "Aucune fourniture trouvé."
+ " Ce code fourniture n'existe pas.",
"Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
}
}
else
{
JOptionPane.showMessageDialog(null, "Saisissez au moins"
+ " un critère de recherche",
"Vérifiez votre saisie", JOptionPane.ERROR_MESSAGE);
}
}
});
}
return btn_Rechercher;
}
public JButton setBtn_EnregistrerActif() {
btn_Enregistrer.setEnabled(true);
return btn_Enregistrer;
}
public JButton setBtn_EnregistrerNonActif() {
btn_Enregistrer.setEnabled(false);
return btn_Enregistrer;
}
public JButton setBtn_SupprimerActif() {
btn_Supprimer.setEnabled(true);
return btn_Supprimer;
}
public JButton setBtn_SupprimerNonActif() {
btn_Supprimer.setEnabled(false);
return btn_Supprimer;
}
public JButton setBtn_RechercherActif() {
btn_Rechercher.setEnabled(true);
return btn_Rechercher;
}
public JButton setBtn_RechercherNonActif() {
btn_Rechercher.setEnabled(false);
return btn_Rechercher;
}
public void changeTitre(String leTitre){
btn_Enregistrer.setText(leTitre);
}
private JButton getBtn_Quitter() {
if (btn_Quitter == null) {
btn_Quitter = new JButton();
btn_Quitter.setBounds(new Rectangle(406, 237, 126, 41));
btn_Quitter.setText("QUITTER");
btn_Quitter.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
FenFicheFourniture.this.dispose();
}
});
}
return btn_Quitter;
}
}
Afficher la suite