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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
| import java.awt.Frame;
import java.awt.Label;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.TextField;
import java.awt.Button;
import java.awt.List;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
public class ClientGraphique extends Frame {
private static final long serialVersionUID = 1L;
private Label label = null;
private Label label1 = null;
private TextField textField = null;
private Button button = null;
private Label label2 = null;
private TextField textField1 = null;
private Button button1 = null;
private Label label3 = null;
private Label label4 = null;
private TextField textField2 = null;
private TextField textField3 = null;
private Button button2 = null;
private Button button3 = null;
private List list = null;
private Button button4 = null;
private Label label5 = null;
/**
* This is the default constructor
*/
public ClientGraphique() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
label5 = new Label();
label5.setBounds(new Rectangle(298, 311, 238, 23));
label5.setText("");
label4 = new Label();
label4.setBounds(new Rectangle(29, 260, 153, 23));
label4.setText("Entrer un montant a retirer");
label3 = new Label();
label3.setBounds(new Rectangle(29, 222, 152, 23));
label3.setText("Entrer un montant a verser");
label2 = new Label();
label2.setBounds(new Rectangle(28, 174, 140, 23));
label2.setText("Rechercher un compte");
label1 = new Label();
label1.setBounds(new Rectangle(30, 116, 137, 23));
label1.setText("Entrer un solde initial");
label = new Label();
label.setBounds(new Rectangle(149, 39, 253, 41));
label.setAlignment(Label.CENTER);
label.setBackground(Color.pink);
label.setForeground(Color.blue);
label.setText("Gestion des comptes bancaires");
this.setLayout(null);
this.setSize(550, 571);
this.setTitle("Gestion Comptes Bancaires");
this.add(label, null);
this.add(label1, null);
this.add(getTextField(), null);
this.add(getButton(), null);
this.add(label2, null);
this.add(getTextField1(), null);
this.add(getButton1(), null);
this.add(label3, null);
this.add(label4, null);
this.add(getTextField2(), null);
this.add(getTextField3(), null);
this.add(getButton2(), null);
this.add(getButton3(), null);
this.add(getList(), null);
this.add(getButton4(), null);
this.add(label5, null);
}
/**
* This method initializes textField
*
* @return java.awt.TextField
*/
private TextField getTextField() {
if (textField == null) {
textField = new TextField();
textField.setBounds(new Rectangle(211, 116, 173, 23));
}
return textField;
}
/**
* This method initializes button
*
* @return java.awt.Button
*/
private Button getButton() {
if (button == null) {
button = new Button();
button.setBounds(new Rectangle(421, 113, 70, 23));
button.setLabel("Créer");
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try{
Socket s=new Socket("localhost",2345);
OutputStream os=s.getOutputStream();
PrintWriter outpw=new PrintWriter(os,true);
outpw.println(textField.getText());
}catch(Exception e1){
e1.printStackTrace();
}// TODO Auto-generated Event stub actionPerformed()
}
});
}
return button;
}
/**
* This method initializes textField1
*
* @return java.awt.TextField
*/
private TextField getTextField1() {
if (textField1 == null) {
textField1 = new TextField();
textField1.setBounds(new Rectangle(210, 173, 175, 23));
}
return textField1;
}
/**
* This method initializes button1
*
* @return java.awt.Button
*/
private Button getButton1() {
if (button1 == null) {
button1 = new Button();
button1.setBounds(new Rectangle(423, 168, 70, 23));
button1.setLabel("Search");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try{
Socket s=new Socket("localhost",2345);
OutputStream os=s.getOutputStream();
PrintWriter outpw=new PrintWriter(os,true);
outpw.println(textField1.getText());
}catch(Exception e1){
e1.printStackTrace();
}// TODO Auto-generated Event stub actionPerformed()
}
});
}
return button1;
}
/**
* This method initializes textField2
*
* @return java.awt.TextField
*/
private TextField getTextField2() {
if (textField2 == null) {
textField2 = new TextField();
textField2.setBounds(new Rectangle(209, 220, 176, 23));
}
return textField2;
}
/**
* This method initializes textField3
*
* @return java.awt.TextField
*/
private TextField getTextField3() {
if (textField3 == null) {
textField3 = new TextField();
textField3.setBounds(new Rectangle(209, 259, 178, 23));
}
return textField3;
}
/**
* This method initializes button2
*
* @return java.awt.Button
*/
private Button getButton2() {
if (button2 == null) {
button2 = new Button();
button2.setBounds(new Rectangle(424, 217, 72, 23));
button2.setLabel("Verser");
button2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try{
Socket s=new Socket("localhost",2345);
OutputStream os=s.getOutputStream();
PrintWriter outpw=new PrintWriter(os,true);
outpw.println(textField2.getText());
}catch(Exception e1){
e1.printStackTrace();
}// TODO Auto-generated Event stub actionPerformed()
}
});
}
return button2;
}
/**
* This method initializes button3
*
* @return java.awt.Button
*/
private Button getButton3() {
if (button3 == null) {
button3 = new Button();
button3.setBounds(new Rectangle(423, 254, 73, 23));
button3.setLabel("Retirer");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try{
Socket s=new Socket("localhost",2345);
OutputStream os=s.getOutputStream();
PrintWriter outpw=new PrintWriter(os,true);
outpw.println(textField2.getText());
}catch(Exception e1){
e1.printStackTrace();
}// TODO Auto-generated Event stub actionPerformed()
}
});
}
return button3;
}
/**
* This method initializes list
*
* @return java.awt.List
*/
private List getList() {
if (list == null) {
list = new List();
list.setBounds(new Rectangle(33, 391, 465, 64));
}
return list;
}
/**
* This method initializes button4
*
* @return java.awt.Button
*/
private Button getButton4() {
if (button4 == null) {
button4 = new Button();
button4.setBounds(new Rectangle(187, 362, 175, 23));
button4.setLabel("Afficher");
button4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try{
Socket s=new Socket("localhost",2345);
InputStream is=s.getInputStream();
ObjectInputStream inois=new ObjectInputStream(is);
label5.setText("(String) inois.readObject()");
}catch(Exception e1){
e1.printStackTrace();
}
}
});
}
return button4;
}
} // @jve:decl-index=0:visual-constraint="10,10" |
Partager