|
1 | 1 | package ihm.alza.InformationCompte;
|
2 | 2 |
|
3 |
| -import java.awt.GridBagLayout; |
| 3 | +import ihm.alza.ModifCompte.ChangerMdp; |
| 4 | +import ihm.alza.PannAdmin.GestionAdmin; |
4 | 5 |
|
5 |
| -import javax.swing.JFrame; |
| 6 | +import java.awt.*; |
| 7 | +import java.awt.event.ActionEvent; |
| 8 | +import java.awt.event.ActionListener; |
| 9 | + |
| 10 | +import javax.swing.*; |
6 | 11 |
|
7 | 12 | @SuppressWarnings("serial")
|
8 |
| -public class InformationAdmin extends JFrame{ |
| 13 | +public class InformationAdmin extends JDialog { |
9 | 14 |
|
10 | 15 | private PannInfAd centre;
|
11 |
| - public InformationAdmin() { |
12 |
| - centre = new PannInfAd(this); |
| 16 | + public InformationAdmin(Frame parent) { |
| 17 | + super(parent, "Informations", true); |
| 18 | + centre = new PannInfAd(); |
13 | 19 | this.setSize(750, 460);
|
14 | 20 | this.setTitle("Information de compte");
|
15 |
| - this.setLocationRelativeTo(null); |
| 21 | + this.setLocationRelativeTo(parent); |
16 | 22 | this.setLayout(new GridBagLayout());
|
17 | 23 |
|
18 | 24 | this.setContentPane(centre);
|
19 |
| - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
| 25 | + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); |
20 | 26 | this.setVisible(true);
|
21 | 27 | }
|
22 |
| -// public static void main(String[] args) { |
23 |
| -// InformationAdmin fen = new InformationAdmin(); |
24 |
| -// } |
| 28 | + |
| 29 | + public class PannInfAd extends JPanel{ |
| 30 | + |
| 31 | + private JTextField prenom; |
| 32 | + private JTextField nom ; |
| 33 | + private JTextField mail; |
| 34 | + |
| 35 | + |
| 36 | + public PannInfAd() { |
| 37 | + GridLayout g = new GridLayout(1,3); |
| 38 | + this.setLayout(g); |
| 39 | + |
| 40 | + GridBagLayout gb = new GridBagLayout(); |
| 41 | + JPanel p = new JPanel(); |
| 42 | + p.setLayout(gb); |
| 43 | + |
| 44 | + GridBagConstraints gbc = new GridBagConstraints(); |
| 45 | + gbc.gridx = 0; |
| 46 | + gbc.gridy = 0; |
| 47 | + |
| 48 | + JLabel mess = new JLabel("Information du compte ",JLabel.CENTER); |
| 49 | + mess.setFont(new Font("Serif", Font.BOLD, 30)); |
| 50 | + JLabel info = new JLabel("Infos Personnels ", JLabel.CENTER); |
| 51 | + JLabel noml = new JLabel("Nom", JLabel.CENTER); |
| 52 | + JLabel prenoml = new JLabel("Prenom", JLabel.CENTER); |
| 53 | + JLabel maill = new JLabel("e-mail ", JLabel.CENTER); |
| 54 | + |
| 55 | + nom = new JTextField(10); |
| 56 | + nom.setEditable(false); |
| 57 | + prenom = new JTextField(10); |
| 58 | + prenom.setEditable(false); |
| 59 | + mail = new JTextField(10); |
| 60 | + mail.setEditable(false); |
| 61 | + |
| 62 | + |
| 63 | + noml.setLabelFor(nom); |
| 64 | + prenoml.setLabelFor(prenom); |
| 65 | + maill.setLabelFor(mail); |
| 66 | + |
| 67 | + |
| 68 | + JButton modifinf = new JButton("Modifier infos"); |
| 69 | + JButton modifmdp = new JButton ("Modifier mot de passe"); |
| 70 | + |
| 71 | + JButton bdd = new JButton("Gestion de la BDD"); |
| 72 | + JButton retour = new JButton("Retour"); |
| 73 | + |
| 74 | + gbc.insets = new Insets(10, 10, 10,10); |
| 75 | + |
| 76 | + gbc.gridx=0; |
| 77 | + gbc.anchor = GridBagConstraints.BASELINE_LEADING; |
| 78 | + p.add(mess,gbc); |
| 79 | + |
| 80 | + gbc.gridy=3; |
| 81 | + gbc.gridx = 0; |
| 82 | + |
| 83 | + p.add(info, gbc); |
| 84 | + |
| 85 | + gbc.gridx=0; |
| 86 | + gbc.gridy=4; |
| 87 | + gbc.anchor = GridBagConstraints.BASELINE_LEADING; |
| 88 | + p.add(noml, gbc); |
| 89 | + gbc.anchor = GridBagConstraints.BASELINE; |
| 90 | + p.add(nom, gbc); |
| 91 | + |
| 92 | + gbc.gridx = 0; |
| 93 | + gbc.gridy=5; |
| 94 | + gbc.anchor = GridBagConstraints.BASELINE_LEADING; |
| 95 | + p.add(prenoml, gbc); |
| 96 | + gbc.anchor = GridBagConstraints.BASELINE; |
| 97 | + p.add(prenom,gbc); |
| 98 | + |
| 99 | + gbc.gridx = 0; |
| 100 | + gbc.gridy=6; |
| 101 | + gbc.anchor = GridBagConstraints.BASELINE_LEADING; |
| 102 | + p.add(maill, gbc); |
| 103 | + gbc.anchor = GridBagConstraints.BASELINE; |
| 104 | + p.add(mail,gbc); |
| 105 | + |
| 106 | + |
| 107 | + gbc.gridx = 0; |
| 108 | + gbc.gridy=7; |
| 109 | + p.add(modifinf, gbc); |
| 110 | + modifinf.addActionListener(new GestAcLis('I')); |
| 111 | + |
| 112 | + gbc.gridy=8; |
| 113 | + p.add(modifmdp, gbc); |
| 114 | + modifmdp.addActionListener(new GestAcLis('M')); |
| 115 | + |
| 116 | + this.add(p); |
| 117 | + |
| 118 | + gbc.gridx = gbc.gridy = 0; |
| 119 | + p = new JPanel(); |
| 120 | + p.setLayout(gb); |
| 121 | + |
| 122 | + |
| 123 | + gbc.gridy++; |
| 124 | + p.add(new JLabel(),gbc); |
| 125 | + gbc.gridy++; |
| 126 | + p.add(new JLabel(),gbc); |
| 127 | + gbc.gridy++; |
| 128 | + p.add(new JLabel(),gbc); |
| 129 | + gbc.gridy++; |
| 130 | + p.add(new JLabel(),gbc); |
| 131 | + gbc.gridy++; |
| 132 | + p.add(new JLabel(),gbc); |
| 133 | + gbc.gridy++; |
| 134 | + p.add(new JLabel(),gbc); |
| 135 | + gbc.gridy++; |
| 136 | + |
| 137 | + gbc.gridwidth = GridBagConstraints.REMAINDER; |
| 138 | + p.add(bdd, gbc); |
| 139 | + bdd.addActionListener(new GestAcLis('B')); |
| 140 | + |
| 141 | + p.add(new JLabel(),gbc); |
| 142 | + gbc.gridy++; |
| 143 | + p.add(new JLabel(),gbc); |
| 144 | + gbc.gridy++; |
| 145 | + p.add(new JLabel(),gbc); |
| 146 | + gbc.gridy++; |
| 147 | + p.add(new JLabel(),gbc); |
| 148 | + gbc.gridy++; |
| 149 | + p.add(new JLabel(),gbc); |
| 150 | + gbc.gridy++; |
| 151 | + p.add(new JLabel(),gbc); |
| 152 | + gbc.gridy++; |
| 153 | + |
| 154 | + gbc.anchor = GridBagConstraints.BASELINE_TRAILING; |
| 155 | + p.add(retour,gbc); |
| 156 | + retour.addActionListener(new GestAcLis('R')); //inutile en soit, peut etre regrouper |
| 157 | + |
| 158 | + this.add(p); |
| 159 | + |
| 160 | + } |
| 161 | + |
| 162 | + class GestAcLis implements ActionListener { |
| 163 | + |
| 164 | + private char c; |
| 165 | + |
| 166 | + public GestAcLis(char c) { |
| 167 | + this.c=c; |
| 168 | + } |
| 169 | + |
| 170 | + @Override |
| 171 | + public void actionPerformed(ActionEvent e) { |
| 172 | + if (c=='I' ) {//Modif Info |
| 173 | + //Alors ca ne marche pas donc je vais faire une autre fenetre ^^' |
| 174 | + new ModifInfAd(null, InformationAdmin.this); |
| 175 | + |
| 176 | +// modifinf = new JButton("Valider Modifications"); |
| 177 | +// nom.setEditable(true); |
| 178 | +// prenom.setEditable(true); |
| 179 | +// mail.setEditable(true); |
| 180 | +// modifinf.addActionListener(new GestAcLis('V')); |
| 181 | + } |
| 182 | +// if(c=='V') { |
| 183 | +// modifinf = new JButton("Modifications Informations"); |
| 184 | +// nom.setEditable(false); |
| 185 | +// prenom.setEditable(false); |
| 186 | +// mail.setEditable(false); |
| 187 | +// modifinf.addActionListener(new GestAcLis('I')); |
| 188 | +// } |
| 189 | + |
| 190 | + if (c=='M' )//Modif Mdp |
| 191 | + new ChangerMdp(null,'A'); |
| 192 | + if (c=='B') |
| 193 | + new GestionAdmin(); |
| 194 | + if (c=='R') |
| 195 | + dispose(); |
| 196 | + } |
| 197 | + |
| 198 | + } |
| 199 | + |
| 200 | + } |
| 201 | + |
25 | 202 | }
|
0 commit comments