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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| public JDialogModifContact(JDialog owner, ArrayList<Contact> alContact) {
super(owner);
this.setLocationRelativeTo(null);
this.setTitle("Liste des contacts");
this.setIconImage(new ImageIcon(getClass().getResource("/images/contact.png")).getImage());
this.alConCree = alContact;
setLayout(new BorderLayout());
JPanel pnlHaut = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridheight = 1;
gbc.gridwidth = 2;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 10, 5, 5);
if(alConCree.size() == 0)
{
comboListe.setEditable(true);
comboListe.setSelectedItem("Aucun contact enregistré");
comboListe.setEditable(false);
}
else
{
String[] tabCon = new String[alConCree.size()];
for(int c = 0 ; c < tabCon.length ; c++)
tabCon[c] = alConCree.get(c).getNom() + " " + alConCree.get(c).getPrenom();
comboListe = new JComboBox(tabCon);
comboListe.setModel(new DefaultComboBoxModel(tabCon));
//comboListe.revalidate();
//comboListe.repaint();
}
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(comboListe, gbc);
gbc.gridwidth = 1;
gbc.gridx+= 2;
JPanel pnlBtnSupEdt = new JPanel();
pnlBtnSupEdt.setLayout(new BoxLayout(pnlBtnSupEdt, BoxLayout.LINE_AXIS));
btnSupCon.setFocusPainted(false);/////////
btnSupCon.setBorderPainted(false);//////// tout ça permet de n'afficher
btnSupCon.setOpaque(false);/////////////// que l'image sur le bouton
btnSupCon.setContentAreaFilled(false);////
btnSupCon.setToolTipText("Supprimer le contact sélectionné");
//btnSupCon.setPreferredSize(new Dimension(17, btnSupCon.getHeight()));
btnEdtCon.setFocusPainted(false);/////////
btnEdtCon.setBorderPainted(false);//////// tout ça permet de n'afficher
btnEdtCon.setOpaque(false);/////////////// que l'image sur le bouton
btnEdtCon.setContentAreaFilled(false);////
btnEdtCon.setToolTipText("Modifier le contact sélectionné");
//btnEdtCon.setPreferredSize(new Dimension(17, btnEdtCon.getHeight()));
pnlBtnSupEdt.add(btnSupCon);
pnlBtnSupEdt.add(btnEdtCon);
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(pnlBtnSupEdt, gbc);
gbc.gridwidth = 1;
gbc.gridx = 0;
gbc.gridy++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(new JLabel("Nom"), gbc);
gbc.gridwidth = 2;
gbc.gridx++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(tfNom, gbc);
gbc.gridwidth = 1;
gbc.gridx = 0;
gbc.gridy++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(new JLabel("Prénom"), gbc);
gbc.gridwidth = 2;
gbc.gridx++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(tfPrenom, gbc);
gbc.gridwidth = 1;
gbc.gridx = 0;
gbc.gridy++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(new JLabel("Fonction"), gbc);
gbc.gridwidth = 2;
gbc.gridx++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(tfFct, gbc);
gbc.gridwidth = 1;
gbc.gridx = 0;
gbc.gridy++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(new JLabel("Téléphone"), gbc);
gbc.gridwidth = 2;
gbc.gridx++;
System.out.println("on ajoute en position x = " + gbc.gridx + " y = " + gbc.gridy + " sur une largeur de " + gbc.gridwidth);
pnlHaut.add(tfTel, gbc);
JPanel pnlBtn = new JPanel();
pnlBtn.setLayout(new BoxLayout(pnlBtn, BoxLayout.LINE_AXIS));
pnlBtn.add(Box.createHorizontalGlue());
btnEdtSav.setEnabled(false);
pnlBtn.add(btnEdtSav);
pnlBtn.add(Box.createRigidArea(new Dimension(10, 0)));
pnlBtn.add(btnCloAnn);
pnlBtn.add(Box.createRigidArea(new Dimension(10, 0)));
this.add(pnlHaut, BorderLayout.NORTH);
this.add(pnlBtn, BorderLayout.CENTER);
this.addWindowListener(this);
this.pack();
this.setResizable(false);
this.setVisible(true);
} |
Partager