-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddAircraftMenu_BP.java
184 lines (143 loc) · 5.42 KB
/
AddAircraftMenu_BP.java
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
package com.company.BigProject;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.ArrayList;
public class AddAircraftMenu_BP extends Container {
public static int idAircraft;
protected JLabel label;
protected JTextField nameAircraft;
protected JTextField modelAircraft;
protected JTextField business_class_capacity;
protected JTextField econom_class_capacity;
protected JButton addButton;
protected JButton backButton;
public AddAircraftMenu_BP(){
setSize(1920,1080);
setLayout(null);
label = new JLabel("NAME : ");
label.setSize(100,30);
label.setLocation(100,60);
add(label);
nameAircraft = new JTextField("");
nameAircraft.setSize(200,30);
nameAircraft.setLocation(200,60);
add(nameAircraft);
label = new JLabel("MODEL : ");
label.setSize(100,30);
label.setLocation(440,60);
add(label);
modelAircraft = new JTextField("");
modelAircraft.setSize(200,30);
modelAircraft.setLocation(560,60);
add(modelAircraft);
label = new JLabel("BUSINESS CLASS CAPACITY : ");
label.setSize(200,30);
label.setLocation(100,140);
add(label);
business_class_capacity = new JTextField("");
business_class_capacity.setSize(100,30);
business_class_capacity.setLocation(300,140);
add(business_class_capacity);
label = new JLabel("ECONOM CLASS CAPACITY : ");
label.setSize(200,30);
label.setLocation(440,140);
add(label);
econom_class_capacity = new JTextField("");
econom_class_capacity.setSize(100,30);
econom_class_capacity.setLocation(660,140);
add(econom_class_capacity);
addButton = new JButton("ADD");
addButton.setSize(100, 30);
addButton.setLocation(100, 200);
add(addButton);
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
String name = nameAircraft.getText();
String model = modelAircraft.getText();
String strBusinessClassCapacity = business_class_capacity.getText();
int businessClassCapacity = Integer.parseInt(strBusinessClassCapacity);
String strEconomClassCapacity = econom_class_capacity.getText();
int economClassCapacity = Integer.parseInt(strEconomClassCapacity);
Aircrafts_BP aircrafts_bp = new Aircrafts_BP(null,name,model,businessClassCapacity,economClassCapacity);
PackageData_BP packageData_bp = new PackageData_BP("ADD AIRCRAFT",aircrafts_bp);
Admin_BP.socket = new Socket("127.0.0.1",3339);
ObjectOutputStream outputStream = new ObjectOutputStream(Admin_BP.socket.getOutputStream());
ObjectInputStream inputStream = new ObjectInputStream(Admin_BP.socket.getInputStream());
outputStream.writeObject(packageData_bp);
}catch (Exception exception){
exception.printStackTrace();
}
nameAircraft.setText("");
modelAircraft.setText("");
business_class_capacity.setText("");
econom_class_capacity.setText("");
}
});
backButton = new JButton("BACK");
backButton.setSize(100, 30);
backButton.setLocation(700, 700);
add(backButton);
backButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Admin_BP.frame.showMenu();
}
});
}
public static int getIdAircraft() {
return idAircraft;
}
public static void setIdAircraft(int id) {
AddAircraftMenu_BP.idAircraft = id;
}
public JLabel getLabel() {
return label;
}
public void setLabel(JLabel label) {
this.label = label;
}
public JTextField getNameAircraft() {
return nameAircraft;
}
public void setNameAircraft(JTextField nameAircraft) {
this.nameAircraft = nameAircraft;
}
public JTextField getModelAircraft() {
return modelAircraft;
}
public void setModelAircraft(JTextField modelAircraft) {
this.modelAircraft = modelAircraft;
}
public JTextField getBusiness_class_capacity() {
return business_class_capacity;
}
public void setBusiness_class_capacity(JTextField business_class_capacity) {
this.business_class_capacity = business_class_capacity;
}
public JTextField getEconom_class_capacity() {
return econom_class_capacity;
}
public void setEconom_class_capacity(JTextField econom_class_capacity) {
this.econom_class_capacity = econom_class_capacity;
}
public JButton getAddButton() {
return addButton;
}
public void setAddButton(JButton addButton) {
this.addButton = addButton;
}
public JButton getBackButton() {
return backButton;
}
public void setBackButton(JButton backButton) {
this.backButton = backButton;
}
}