1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
package com.clearstream.main;
import java.awt.GridBagConstraints;
import java.awt.Insets;
public class EastPanel extends JPanel {
private static final long serialVersionUID = 1L;
public JPanel eastPanel = new JPanel();
public JLabel matriculeLabel = new JLabel("Matricule :");
public JLabel nomLabel = new JLabel("Nom :");
public JLabel prenomLabel = new JLabel("Prénom :");
public JLabel fonctionLabel = new JLabel("Fonction :");
public JLabel sexeLabel = new JLabel("Sexe :");
public GridBagConstraints gbc = new GridBagConstraints();
public EastPanel(String name) {
initPanel(name);
}
public void initPanel(String name) {
this.setName(name);
//this.eastPanel.setLayout( new GridBagLayout() );
/* a- ajout du label contenant le matricule. */
this.gbc.gridx = 0;
this.gbc.gridy = 0;
this.gbc.gridwidth = GridBagConstraints.REMAINDER; // gbc.gridheight = 1;
this.gbc.insets = new Insets(0, 5, 0, 0);
/* Le point d'ancrage ici n'a pas une grande importance. Nous allons quand même essayer d'aligner tout les
* composants qui le peuvent sur leur ligne de base. */
this.gbc.anchor = GridBagConstraints.BASELINE_LEADING;
this.eastPanel.add(this.matriculeLabel, gbc);
/* c- étiquette contenant le nom. */
this.gbc.gridx = 1;
this.gbc.gridy = 1;
this.gbc.gridwidth = 1;
this.gbc.gridheight = 1;
/* L'étiquette avec le nom sera alignée sur la ligne de base avec le champ de saisie pour le nom. */
this.gbc.anchor = GridBagConstraints.BASELINE_LEADING;
this.gbc.insets = new Insets(0, 5, 0, 0);
this.eastPanel.add(this.nomLabel, gbc);
/* e- l'étiquette pour le prénom. */
this.gbc.gridx = 1;
this.gbc.gridy = 2;
this.gbc.gridwidth = 1;
this.gbc.gridheight = 1;
this.gbc.fill = GridBagConstraints.NONE;
this.gbc.anchor = GridBagConstraints.BASELINE_LEADING;
this.gbc.insets = new Insets(0, 5, 0, 0);
this.eastPanel.add(this.prenomLabel, gbc);
/* g- l'étiquette pour la fonction. */
this.gbc.gridx = 1;
this.gbc.gridwidth = 1;
this.gbc.gridheight = 1;
this.gbc.gridy = 3;
this.gbc.fill = GridBagConstraints.NONE;
this.gbc.anchor = GridBagConstraints.BASELINE_LEADING;
this.gbc.insets = new Insets(0, 5, 0, 0);
this.eastPanel.add(this.fonctionLabel, gbc);
}
} |
Partager