Bon, ben mon logiciel avance...
j'en suis à plus de 8300 lignes de code et à peu près aux 8/10 de la totale.
Par contre Bobo, je ne m'y suis pas encore penché (j'ai bien d'autres methodes à implémenter!), mais j'aimerais rajouter un champ dans la fenetre que tu m'a faite (sous les champs "Dates" par exemple) et comme j'ai toujours du mal avec ces putains de gridBagLayout....
Tu lui indique la ligne et la colonne, ok, mais en combien le JPanel est-il divisé ???
package IHM; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import Utilities.Entreprise; import Utilities.Fichier; import Utilities.Machine; public class IhmDonneesEntreprise extends JDialog implements ActionListener { /** Gestionnaire de mise en pages */ private GridBagLayout gridBagLayout = new GridBagLayout(); private BorderLayout borderLayout = new BorderLayout(); private GridBagConstraints c = new GridBagConstraints(); /** Ensemble des JButton */ private JButton ok, annuler; /** Ensemble des JPanel */ private JPanel contentPane, machPane, datePane, entrPane, calPane, buttonPane, tempPane; /** Ensemble des JLabel */ // Labels machPane private JLabel resMach = new JLabel("<html><p><b>Machine</b></p></html>"); private JLabel labelRefMach = new JLabel("Ref : "); private JLabel labNumMach = new JLabel("N° : "); // Labels datePane private JLabel labelDate = new JLabel("Dates (jj/mm/aa)"); private JLabel labelDbt = new JLabel("*Début : "); private JLabel labelFin = new JLabel("*Fin : "); // Labels calPane private JLabel labelCal = new JLabel("*Commercial : "); private JLabel labelTech = new JLabel("*Technicien : "); // Labels Entreprise private JLabel labelEntreprise = new JLabel("<html><p><b>Entreprise</b></p></html>"); private JLabel labelNomEntre = new JLabel("*Nom : "); private JLabel labelNumTelEntre = new JLabel("*N° Tel : "); private JLabel labelAdrEntre = new JLabel("*Adresse : "); private JLabel labelCodPostalEntre = new JLabel("*Code Postal : "); private JLabel labelContactEntre = new JLabel("*Contact : "); private JLabel labelInfoEntre = new JLabel("Info : "); /** Ensemble des JTextField */ // Champs machPane public JTextField champsRefMach = new JTextField(10); public JTextField champsNumMach = new JTextField(10); // Champs datePane private JTextField champsDbt = new JTextField(8); private JTextField champsFin = new JTextField(8); // Champs calPane private JTextField champsCal = new JTextField(10); private JTextField champsTech = new JTextField(10); // Champs entrPane private JTextField champsNomEntre = new JTextField(10); private JTextField champsNumTelEntre = new JTextField(10); private JTextArea champsAdrEntre = new JTextArea(3, 20); private JTextField champsCodPostalEntre = new JTextField(5); private JTextField champsContactEntre = new JTextField(10); private JTextArea champsInfoEntre = new JTextArea(4, 20); private Toolkit tool = null; private Entreprise existeEnt; private Machine machine; public boolean resultat = false; public IhmDonneesEntreprise(JFrame parent,String title, Machine mach)//Constructeur pour champs vides sauf machine { super(parent,title,true);//On instancie un JDialog modal this.addWindowListener(new WindowAdapter() { public void windowIconified(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } }); // Création et installation des composants (liste, boutons) creeComposants(); // Initialisation de la taille et de la position de la fenêtre setup(); machine = mach; setChampsMachine(machine);//on pré-remplis les champs machine setVisible(true);// On rend la fenêtre visible } public IhmDonneesEntreprise(JFrame parent,String title,Entreprise ent)//Constructeur pour champs pré-remplis { super(parent,title,true);//On instancie un JDialog modal this.addWindowListener(new WindowAdapter() { public void windowIconified(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } }); // Création et installation des composants (liste, boutons) creeComposants(); // Initialisation de la taille et de la position de la fenêtre setup(); existeEnt = ent; setChamps(existeEnt);//On pré-rempli les champs setVisible(true);// On rend la fenêtre visible } /** Initialisation de la taille et de la position de la fenêtre */ private void setup() { tool = this.getToolkit();//permet l'utilisation d'un beep sonore par // exemple //On adapte la taille de la fenetre principale à la résolution de // l'ecran Client Dimension tailleEcran = Toolkit.getDefaultToolkit().getScreenSize(); //int largeur = (tailleEcran.width)/ 2; //int hauteur = (tailleEcran.height); int largeur = 450; int hauteur = 500; setSize(largeur, hauteur); int yPos = (tailleEcran.width ) / 4; int xPos = (tailleEcran.height ) / 15; setLocation(yPos, xPos); setResizable(false); } private void creeComposants() { /** Initialisation des JPanel */ // init contentPane contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(gridBagLayout); // init machPane machPane = new JPanel(); machPane.setLayout(gridBagLayout); // init datePane datePane = new JPanel(); datePane.setLayout(gridBagLayout); // init calPane calPane = new JPanel(); calPane.setLayout(gridBagLayout); // init entrPane entrPane = new JPanel(); entrPane.setLayout(gridBagLayout); // init buttonPane buttonPane = new JPanel(); buttonPane.setLayout(gridBagLayout); /** Initialisation des JButton */ // bouton 'Ok' ok = new JButton(" Ok "); ok.addActionListener(this); ok.setActionCommand("OK"); // bouton 'Annuler' annuler = new JButton("Annuler"); annuler.addActionListener(this); annuler.setActionCommand("ANNULER"); // Ajout des labels c.anchor = GridBagConstraints.WEST;//accrochage du coin gauche à gauche du Panel principal c.fill = GridBagConstraints.BOTH;//on rempli vertical et horizontal c.insets = new Insets(0, 4, 0, 0);//ecart entre objet (haut,gauche,bas,droite) /** construction machPane */ // label machine c.gridx = 0;//position en colonne c.gridy = 2; // Colonne 0, Ligne 2//position en ligne c.gridwidth = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule) c.gridheight = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule) gridBagLayout.setConstraints(resMach, c); machPane.add(resMach); // label ref c.gridx = 3; c.gridy = 4; // Colonne 3, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelRefMach, c); machPane.add(labelRefMach); // champs ref c.gridx = 5; c.gridy = 4; // Colonne 5, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(champsRefMach, c); machPane.add(champsRefMach); // label num c.gridx = 8; c.gridy = 4; // Colonne 8, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labNumMach, c); machPane.add(labNumMach); // champs num c.gridwidth = 1; c.gridheight = 1; c.gridx = 10; gridBagLayout.setConstraints(champsNumMach, c); machPane.add(champsNumMach); /** contruction datePane */ // Ajout des labels c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; // label date c.gridx = 0; c.gridy = 2; // Colonne 0, Ligne 2 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelDate, c); datePane.add(labelDate); // label Début c.gridx = 0; c.gridy = 4; // Colonne 3, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelDbt, c); datePane.add(labelDbt); // champs Début c.gridx = 5; c.gridy = 4; // Colonne 5, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(champsDbt, c); datePane.add(champsDbt); // label Fin c.gridx = 7; // Colonne 7, Ligne 4 c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right gridBagLayout.setConstraints(labelFin, c); datePane.add(labelFin); // champs Fin c.gridwidth = 1; c.gridheight = 1; c.gridx = 9; // Colonne 9, Ligne 4 gridBagLayout.setConstraints(champsFin, c); datePane.add(champsFin); /** contruction calPane */ // Ajout des labels c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; // label commercial c.gridx = 0; c.gridy = 2; // Colonne 0, Ligne 2 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelCal, c); calPane.add(labelCal); // champs commercial c.gridx = 10; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right gridBagLayout.setConstraints(champsCal, c); calPane.add(champsCal); // label Technicien c.gridwidth = 1; c.gridheight = 1; c.gridx = 12; gridBagLayout.setConstraints(labelTech, c); calPane.add(labelTech); // champs Technicien c.gridwidth = 1; c.gridheight = 1; c.gridx = 20; gridBagLayout.setConstraints(champsTech, c); calPane.add(champsTech); /** construction entrPane */ // Ajout des labels c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(4, 4, 0, 0); //top, left, bottom, right // label Entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 2; // Colonne 0, Ligne 2 gridBagLayout.setConstraints(labelEntreprise, c); entrPane.add(labelEntreprise); // label nom entreprise c.gridx = 0; c.gridy = 4; // Colonne 0, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelNomEntre, c); entrPane.add(labelNomEntre); // champs nom entreprise c.gridx = 2; c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(champsNomEntre, c); entrPane.add(champsNomEntre); // label num tel c.gridwidth = 1; c.gridheight = 1; c.gridx = 4; // Colonne 5, Ligne 4 gridBagLayout.setConstraints(labelNumTelEntre, c); entrPane.add(labelNumTelEntre); // champs tel entreprise c.weightx = 1.0; c.gridwidth = 1; c.gridheight = 1; c.gridx = 6; // Colonne 6, Ligne 4 gridBagLayout.setConstraints(champsNumTelEntre, c); entrPane.add(champsNumTelEntre); // label adresse c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 6; // Colonne 0, Ligne 6 gridBagLayout.setConstraints(labelAdrEntre, c); entrPane.add(labelAdrEntre); // champs adresse entreprise c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 2; c.gridheight = 1; /** On souhaite un retour à ligne automatique : */ champsAdrEntre.setLineWrap(true); /** On souhaite que les mots ne soient pas coupés : */ champsAdrEntre.setWrapStyleWord(true); JScrollPane scrollAdr = new JScrollPane(champsAdrEntre); gridBagLayout.setConstraints(scrollAdr, c); entrPane.add(scrollAdr); // label code postal c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 8; // Colonne 0, Ligne 8 gridBagLayout.setConstraints(labelCodPostalEntre, c); entrPane.add(labelCodPostalEntre); // champs code postal entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 2; // Colonne 2, Ligne 8 gridBagLayout.setConstraints(champsCodPostalEntre, c); entrPane.add(champsCodPostalEntre); // label contact entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 4; // Colonne 6, Ligne 8 gridBagLayout.setConstraints(labelContactEntre, c); entrPane.add(labelContactEntre); // champs contact entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 6; // Colonne 6, Ligne 8 gridBagLayout.setConstraints(champsContactEntre, c); entrPane.add(champsContactEntre); // label info Entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 10; // Colonne 0, Ligne 10 c.insets = new Insets(20, 4, 0, 0); //top, left, bottom, right gridBagLayout.setConstraints(labelInfoEntre, c); entrPane.add(labelInfoEntre); // champs contact entreprise c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 2; // Colonne 2, Ligne 10 c.gridheight = 1; /** On souhaite un retour à ligne automatique : */ champsInfoEntre.setLineWrap(true); /** On souhaite que les mots ne soient pas coupés : */ champsInfoEntre.setWrapStyleWord(true); JScrollPane scrollInfo = new JScrollPane(champsInfoEntre); gridBagLayout.setConstraints(scrollInfo, c); entrPane.add(scrollInfo); /** Construction buttonPane */ FlowLayout flow = new FlowLayout(); buttonPane.setLayout(flow); buttonPane.add(ok); buttonPane.add(annuler); /** contruction contentPane */ contentPane.add(machPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 9, 0), 1, 2)); contentPane.add(datePane, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 9, 0), 1, 2)); contentPane.add(calPane, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 0, 9, 0), 1, 2)); contentPane.add(entrPane, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 0, 0, 0), 1, 2)); JLabel use = new JLabel("* Champs obligatoires"); contentPane.add(use, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 1, 2)); contentPane.add(buttonPane, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 1, 2)); contentPane.validate(); } public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand() == "ANNULER") { dispose(); } if (evt.getActionCommand() == "OK") { Fichier.miseAjourDonnees();//on recharge si neccessaire if(existeEnt!=null)//si on est dans le cas de changement de données d'une entreprise existante { existeEnt.setDateDebut(champsDbt.getText()); existeEnt.setDateFin(champsFin.getText()); existeEnt.setNom(champsNomEntre.getText()); existeEnt.setAdresse(champsAdrEntre.getText()); existeEnt.setCodePostal(champsCodPostalEntre.getText()); existeEnt.setPersonne(champsContactEntre.getText()); existeEnt.setNumeroDeTel(champsNumTelEntre.getText()); existeEnt.setCommercial(champsCal.getText()); existeEnt.setTechnicien(champsTech.getText()); existeEnt.setInfo(champsInfoEntre.getText()); Fichier.miseAjourFichier(); Fichier.miseAjourDonnees(); dispose(); JOptionPane.showConfirmDialog(contentPane,"Données Entreprise modifiées !","Confirmation modification",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE); } else//si on est dans le cas de la création d'une nouvelle entreprise { Entreprise nouvelle = machine.createEntreprise(); nouvelle.setDateDebut(champsDbt.getText()); nouvelle.setDateFin(champsFin.getText()); nouvelle.setNom(champsNomEntre.getText()); nouvelle.setAdresse(champsAdrEntre.getText()); nouvelle.setCodePostal(champsCodPostalEntre.getText()); nouvelle.setPersonne(champsContactEntre.getText()); nouvelle.setNumeroDeTel(champsNumTelEntre.getText()); nouvelle.setCommercial(champsCal.getText()); nouvelle.setTechnicien(champsTech.getText()); nouvelle.setInfo(champsInfoEntre.getText()); machine.miseAjourHistorique(nouvelle); Fichier.miseAjourFichier(); Fichier.miseAjourDonnees(); resultat = true; dispose(); JOptionPane.showConfirmDialog(contentPane,"Nouvelle entreprise ajoutée dans l'historique!","Confirmation création",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE); } } } public void setChamps(Entreprise en) { champsRefMach.setText(en.referenceMachine); champsNumMach.setText(en.numeroSerieMachine); champsDbt.setText(en.dateDebut); champsFin.setText(en.dateFin); champsCal.setText(en.commercial); champsTech.setText(en.technicien); champsNomEntre.setText(en.nom); champsNumTelEntre.setText(en.numeroDeTel); champsAdrEntre.setText(en.adresse); champsCodPostalEntre.setText(en.codePostal); champsContactEntre.setText(en.personneAcontacter); champsInfoEntre.setText(en.info); } public void setChampsMachine(Machine ma) { champsRefMach.setText(ma.getRef()); champsNumMach.setText(ma.getNumeroSerie()); } }//checksum=445
Hors ligne
Si c'est dans le panel de date que tu veut acjouter ton champs tu fait :
// champs tonChamps
c.gridwidth = 1;
c.gridheight = 1;
c.gridy = 6;
c.gridx = 0; // Colonne 9, Ligne 4
gridBagLayout.setConstraints(tonChamps, c);
datePane.add(tonChamps);
c'est tout.
Hors ligne
Borusse a écrit:
Si c'est dans le panel de date que tu veut acjouter ton champs tu fait :
// champs tonChamps
c.gridwidth = 1;
c.gridheight = 1;
c.gridy = 6;
c.gridx = 0; // Colonne 9, Ligne 4
gridBagLayout.setConstraints(tonChamps, c);
datePane.add(tonChamps);
c'est tout.
Heu...dans ton code tu dis colonne 9 mais tu mets c.gridx = 0;
Hors ligne
Bon ok, j'ai modifié, mais les champs "commercial" et "Technicien" sont trop hauts ( alors que je ne vois pas pourquoi il change de taille) !!
import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.UIManager; public class IhmDonneesEntreprise extends JDialog implements ActionListener { /** Gestionnaire de mise en pages */ private GridBagLayout gridBagLayout = new GridBagLayout(); private BorderLayout borderLayout = new BorderLayout(); private GridBagConstraints c = new GridBagConstraints(); /** Ensemble des JButton */ private JButton ok, annuler; /** Ensemble des JPanel */ private JPanel contentPane, machPane, datePane, entrPane, calPane, buttonPane, tempPane; /** Ensemble des JLabel */ // Labels machPane private JLabel resMach = new JLabel("<html><p><b>Machine</b></p></html>"); private JLabel labelRefMach = new JLabel("Ref : "); private JLabel labNumMach = new JLabel("N° : "); private JLabel labelChrono = new JLabel("N° Chrono :"); private JLabel labelStatut = new JLabel("Statut :"); // Labels datePane private JLabel labelDate = new JLabel("Dates (jj/mm/aa)"); private JLabel labelDbt = new JLabel("*Début : "); private JLabel labelFin = new JLabel("*Fin : "); // Labels calPane private JLabel labelCal = new JLabel("*Commercial : "); private JLabel labelTech = new JLabel("*Technicien : "); // Labels Entreprise private JLabel labelEntreprise = new JLabel("<html><p><b>Entreprise</b></p></html>"); private JLabel labelNomEntre = new JLabel("*Nom : "); private JLabel labelNumTelEntre = new JLabel("*N° Tel : "); private JLabel labelAdrEntre = new JLabel("*Adresse : "); private JLabel labelCodPostalEntre = new JLabel("*Code Postal : "); private JLabel labelContactEntre = new JLabel("*Contact : "); private JLabel labelInfoEntre = new JLabel("Info : "); /** Ensemble des JTextField */ // Champs machPane public JTextField champsRefMach = new JTextField(10); public JTextField champsNumMach = new JTextField(10); public JTextField champsChrono = new JTextField(10); public JTextField champsStatut = new JTextField(10); // Champs datePane private JTextField champsDbt = new JTextField(8); private JTextField champsFin = new JTextField(8); // Champs calPane private JTextField champsCal = new JTextField(10); private JTextField champsTech = new JTextField(10); // Champs entrPane private JTextField champsNomEntre = new JTextField(10); private JTextField champsNumTelEntre = new JTextField(10); private JTextArea champsAdrEntre = new JTextArea(3, 20); private JTextField champsCodPostalEntre = new JTextField(5); private JTextField champsContactEntre = new JTextField(10); private JTextArea champsInfoEntre = new JTextArea(4, 20); private Toolkit tool = null; public boolean resultat = false; public IhmDonneesEntreprise(JFrame parent,String title)//Constructeur pour champs vides { super(parent,title,true);//On instancie un JDialog modal this.addWindowListener(new WindowAdapter() { public void windowIconified(WindowEvent e) { } public void windowClosing(WindowEvent e) { dispose(); } }); // Création et installation des composants (liste, boutons) creeComposants(); // Initialisation de la taille et de la position de la fenêtre setup(); setVisible(true);// On rend la fenêtre visible } /** Initialisation de la taille et de la position de la fenêtre */ private void setup() { tool = this.getToolkit();//permet l'utilisation d'un beep sonore par // exemple //On adapte la taille de la fenetre principale à la résolution de // l'ecran Client Dimension tailleEcran = Toolkit.getDefaultToolkit().getScreenSize(); //int largeur = (tailleEcran.width)/ 2; //int hauteur = (tailleEcran.height); int largeur = 500; int hauteur = 550; setSize(largeur, hauteur); int yPos = (tailleEcran.width ) / 4; int xPos = (tailleEcran.height ) / 15; setLocation(yPos, xPos); setResizable(true); } private void creeComposants() { /** Initialisation des JPanel */ // init contentPane contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(gridBagLayout); // init machPane machPane = new JPanel(); machPane.setLayout(gridBagLayout); // init datePane datePane = new JPanel(); datePane.setLayout(gridBagLayout); // init calPane calPane = new JPanel(); calPane.setLayout(gridBagLayout); // init entrPane entrPane = new JPanel(); entrPane.setLayout(gridBagLayout); // init buttonPane buttonPane = new JPanel(); buttonPane.setLayout(gridBagLayout); /** Initialisation des JButton */ // bouton 'Ok' ok = new JButton(" Ok "); ok.addActionListener(this); ok.setActionCommand("OK"); // bouton 'Annuler' annuler = new JButton("Annuler"); annuler.addActionListener(this); annuler.setActionCommand("ANNULER"); // Ajout des labels c.anchor = GridBagConstraints.WEST;//accrochage du coin gauche à gauche du Panel principal c.fill = GridBagConstraints.BOTH;//on rempli vertical et horizontal c.insets = new Insets(0, 4, 0, 0);//ecart entre objet (haut,gauche,bas,droite) /** construction machPane */ // label machine c.gridx = 0;//position en colonne c.gridy = 2; // Colonne 0, Ligne 2//position en ligne c.gridwidth = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule) c.gridheight = 1;//fusionnement de plusieurs cellules ou pas (1 = 1 cellule) gridBagLayout.setConstraints(resMach, c); machPane.add(resMach); // label ref c.gridx = 3; c.gridy = 4; // Colonne 3, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelRefMach, c); machPane.add(labelRefMach); // champs ref c.gridx = 5; c.gridy = 4; // Colonne 5, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(champsRefMach, c); machPane.add(champsRefMach); // label num c.gridx = 8; c.gridy = 4; // Colonne 8, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labNumMach, c); machPane.add(labNumMach); // champs num c.gridwidth = 1; c.gridheight = 1; c.gridx = 10; gridBagLayout.setConstraints(champsNumMach, c); machPane.add(champsNumMach); /** contruction datePane */ // Ajout des labels c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; // label date c.gridx = 0; c.gridy = 2; // Colonne 0, Ligne 2 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelDate, c); datePane.add(labelDate); // label Début c.gridx = 0; c.gridy = 4; // Colonne 3, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelDbt, c); datePane.add(labelDbt); // champs Début c.gridx = 5; c.gridy = 4; // Colonne 5, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(champsDbt, c); datePane.add(champsDbt); // label Fin c.gridx = 7; // Colonne 7, Ligne 4 c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right gridBagLayout.setConstraints(labelFin, c); datePane.add(labelFin); // champs Fin c.gridwidth = 1; c.gridheight = 1; c.gridx = 9; // Colonne 9, Ligne 4 gridBagLayout.setConstraints(champsFin, c); datePane.add(champsFin); /** contruction calPane */ // Ajout des labels c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; /**+++++++++++++++++++++MODIFCATION+++++++++++++++++++++++++++*/ // c.gridx = 0; c.gridx = 0; c.gridy = 2; // Colonne 0, Ligne 2 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelChrono, c); calPane.add(labelChrono); // champs chrono c.gridx = 10; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(10, 4, 10, 0); //top, left, bottom, right gridBagLayout.setConstraints(champsChrono, c); calPane.add(champsChrono); // label statut c.gridwidth = 1; c.gridheight = 1; c.gridx = 12; gridBagLayout.setConstraints(labelStatut, c); calPane.add(labelStatut); // champs statut c.gridwidth = 1; c.gridheight = 1; c.gridx = 20; gridBagLayout.setConstraints(champsStatut, c); calPane.add(champsStatut); /**+++++++++++++++++++++ FIN MODIFCATION+++++++++++++++++++++++++++*/ // label commercial c.gridx = 0; c.gridy = 3; // Colonne 0, Ligne 2 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelCal, c); calPane.add(labelCal); // champs commercial c.gridx = 10; c.gridwidth = 1; c.gridheight = 1; c.insets = new Insets(0, 4, 0, 0); //top, left, bottom, right gridBagLayout.setConstraints(champsCal, c); calPane.add(champsCal); // label Technicien c.gridwidth = 1; c.gridheight = 1; c.gridx = 12; gridBagLayout.setConstraints(labelTech, c); calPane.add(labelTech); // champs Technicien c.gridwidth = 1; c.gridheight = 1; c.gridx = 20; gridBagLayout.setConstraints(champsTech, c); calPane.add(champsTech); /** construction entrPane */ // Ajout des labels c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.NONE; c.insets = new Insets(4, 4, 0, 0); //top, left, bottom, right // label Entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 2; // Colonne 0, Ligne 2 gridBagLayout.setConstraints(labelEntreprise, c); entrPane.add(labelEntreprise); // label nom entreprise c.gridx = 0; c.gridy = 4; // Colonne 0, Ligne 4 c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(labelNomEntre, c); entrPane.add(labelNomEntre); // champs nom entreprise c.gridx = 2; c.gridwidth = 1; c.gridheight = 1; gridBagLayout.setConstraints(champsNomEntre, c); entrPane.add(champsNomEntre); // label num tel c.gridwidth = 1; c.gridheight = 1; c.gridx = 4; // Colonne 5, Ligne 4 gridBagLayout.setConstraints(labelNumTelEntre, c); entrPane.add(labelNumTelEntre); // champs tel entreprise c.weightx = 1.0; c.gridwidth = 1; c.gridheight = 1; c.gridx = 6; // Colonne 6, Ligne 4 gridBagLayout.setConstraints(champsNumTelEntre, c); entrPane.add(champsNumTelEntre); // label adresse c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 6; // Colonne 0, Ligne 6 gridBagLayout.setConstraints(labelAdrEntre, c); entrPane.add(labelAdrEntre); // champs adresse entreprise c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 2; c.gridheight = 1; /** On souhaite un retour à ligne automatique : */ champsAdrEntre.setLineWrap(true); /** On souhaite que les mots ne soient pas coupés : */ champsAdrEntre.setWrapStyleWord(true); JScrollPane scrollAdr = new JScrollPane(champsAdrEntre); gridBagLayout.setConstraints(scrollAdr, c); entrPane.add(scrollAdr); // label code postal c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 8; // Colonne 0, Ligne 8 gridBagLayout.setConstraints(labelCodPostalEntre, c); entrPane.add(labelCodPostalEntre); // champs code postal entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 2; // Colonne 2, Ligne 8 gridBagLayout.setConstraints(champsCodPostalEntre, c); entrPane.add(champsCodPostalEntre); // label contact entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 4; // Colonne 6, Ligne 8 gridBagLayout.setConstraints(labelContactEntre, c); entrPane.add(labelContactEntre); // champs contact entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 6; // Colonne 6, Ligne 8 gridBagLayout.setConstraints(champsContactEntre, c); entrPane.add(champsContactEntre); // label info Entreprise c.gridwidth = 1; c.gridheight = 1; c.gridx = 0; c.gridy = 10; // Colonne 0, Ligne 10 c.insets = new Insets(20, 4, 0, 0); //top, left, bottom, right gridBagLayout.setConstraints(labelInfoEntre, c); entrPane.add(labelInfoEntre); // champs contact entreprise c.gridwidth = GridBagConstraints.REMAINDER; c.gridx = 2; // Colonne 2, Ligne 10 c.gridheight = 1; /** On souhaite un retour à ligne automatique : */ champsInfoEntre.setLineWrap(true); /** On souhaite que les mots ne soient pas coupés : */ champsInfoEntre.setWrapStyleWord(true); JScrollPane scrollInfo = new JScrollPane(champsInfoEntre); gridBagLayout.setConstraints(scrollInfo, c); entrPane.add(scrollInfo); /** Construction buttonPane */ FlowLayout flow = new FlowLayout(); buttonPane.setLayout(flow); buttonPane.add(ok); buttonPane.add(annuler); /** contruction contentPane */ contentPane.add(machPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 9, 0), 1, 2)); contentPane.add(datePane, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 9, 0), 1, 2)); contentPane.add(calPane, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 0, 9, 0), 1, 2)); contentPane.add(entrPane, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 0, 0, 0), 1, 2)); JLabel use = new JLabel("* Champs obligatoires"); contentPane.add(use, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 1, 2)); contentPane.add(buttonPane, new GridBagConstraints(0, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 1, 2)); contentPane.validate(); } public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand() == "ANNULER") { System.exit(0); } if (evt.getActionCommand() == "OK") { System.exit(0); } } public static void main(String arg[]) { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch(Exception e) { e.printStackTrace(); } IhmDonneesEntreprise test = new IhmDonneesEntreprise(null, "test"); } }//Fin de classe
Dernière modification par papy (18-03-2005 12:36:24)
Hors ligne
ouais, pour le commentaire j'ai oublié de le modifier.
Pour ce qui est de la taille des champs tech et calk cela vient du fait qu'ils s'adaptent à la taille de la colonne c'est tout.
Enplus t'as rajouté de nouveaux composants, duy cou p il faut tout que tu ré-aligneavec ceux des autres panels pour que cela soit joli.
Hors ligne
Borusse a écrit:
ouais, pour le commentaire j'ai oublié de le modifier.
Pour ce qui est de la taille des champs tech et calk cela vient du fait qu'ils s'adaptent à la taille de la colonne c'est tout.
Enplus t'as rajouté de nouveaux composants, duy cou p il faut tout que tu ré-aligneavec ceux des autres panels pour que cela soit joli.
Pour l'alignement ils sont alignés, ok, mais pour la hauteur des 2 JtextField je capte pas!
Hors ligne
qu'est ce que tu appels la hauteur des JTextField, la hauteur sur le panel ou la hauteur interne (plus gros quoi) ?
Hors ligne
Laisse béton ça fait des jours que mon problème est résolu.
Mais merci pour ta réactivité!
LOOOOOOL
Hors ligne