-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearchFlight.java
More file actions
205 lines (165 loc) · 5.5 KB
/
searchFlight.java
File metadata and controls
205 lines (165 loc) · 5.5 KB
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
import java.awt.*;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.*;
public class searchFlight extends JFrame{
// JFrame mainPanel=new JFrame();
JLabel ino1=new JLabel("Identity Number");
JTextField tino1=new JTextField();
JLabel ino2=new JLabel("From");
JTextField tino2=new JTextField();
JLabel ino3=new JLabel("To");
JTextField tino3=new JTextField();
JLabel ino4=new JLabel("Arrival Time");
JTextField tino4=new JTextField();
JLabel ino5=new JLabel("Departure Time");
JTextField tino5=new JTextField();
JLabel ino6=new JLabel("Flight Name");
JTextField tino6=new JTextField();
JLabel ino7=new JLabel("Seats Available");
JTextField tino7=new JTextField();
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JButton search=new JButton("Search");
Container pane=getContentPane();
searchFlight()
{
pane.setLayout(new GridLayout(7,1));
p1.setLayout(new GridLayout(7,1));
pane.add(p1);
pane.add(p2);
p1.add(ino1);
p1.add(tino1);
p1.add(ino2);
p1.add(tino2);
p1.add(ino3);
p1.add(tino3);
p1.add(ino4);
p1.add(tino4);
p1.add(ino5);
p1.add(tino5);
p1.add(ino6);
p1.add(tino6);
p1.add(ino7);
p1.add(tino7);
p2.add(search);
listener l=new listener();
search.addActionListener(l);
Border newone = BorderFactory.createEmptyBorder(10, 10, 10, 10);
((JComponent) pane).setBorder(newone);
setTitle("Flight Details");
setSize(500,300);
setMinimumSize(new Dimension(500,600));
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
}
class listener implements ActionListener{
public void actionPerformed(ActionEvent evt) {
// String id=tino.getText();
if(tino1.getText().length()==0) {
JOptionPane.showMessageDialog(null, "Enter the Identity Number!", "Airlines", 1);
}
else
{
new tickets();
//JOptionPane.showMessageDialog(null, "No Flights Booked for entered Identity Number", "Airlines", 1);
// setVisible(false);
}
}
}
public static void main(String[] args)
{
new searchFlight();
}
}
/*
* import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Login extends JFrame implements ActionListener {
String firstName;
String lastName;
JTextField fn, ln, phoneNumber, email;
JPasswordField pass;
Login(String a, String b) {
this.firstName = a;
this.lastName = b;
setUp();
setVisible(true);
}
void setUp() {
setMinimumSize(new Dimension(500, 600));
fn = new JTextField();
ln = new JTextField();
phoneNumber = new JTextField(); // Added phone number field
email = new JTextField(); // Added email field
JLabel f = new JLabel("First Name");
JLabel l = new JLabel("Last Name");
JLabel phoneLabel = new JLabel("Phone Number"); // Added label for phone number
JLabel emailLabel = new JLabel("Email"); // Added label for email
pass = new JPasswordField();
JLabel passLabel = new JLabel("Password");
JButton b = new JButton("Login");
b.addActionListener(this);
Container pane = getContentPane();
setTitle("Login");
pane.setLayout(new GridBagLayout()); // Used GridBagLayout for centering
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(10, 10, 10, 10); // Added insets for spacing
// First column
gbc.gridx = 0;
gbc.gridy = 0;
pane.add(f, gbc);
gbc.gridy = 1;
pane.add(l, gbc);
gbc.gridy = 2;
pane.add(phoneLabel, gbc);
gbc.gridy = 3;
pane.add(emailLabel, gbc);
gbc.gridy = 4;
pane.add(passLabel, gbc);
// Second column
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0; // Allow components to expand horizontally
gbc.fill = GridBagConstraints.HORIZONTAL;
pane.add(fn, gbc);
gbc.gridy = 1;
pane.add(ln, gbc);
gbc.gridy = 2;
pane.add(phoneNumber, gbc);
gbc.gridy = 3;
pane.add(email, gbc);
gbc.gridy = 4;
pane.add(pass, gbc);
gbc.gridy = 5;
gbc.anchor = GridBagConstraints.CENTER; // Align the button to the center
pane.add(b, gbc);
b.setPreferredSize(new Dimension(80, 20)); // Set the size of the "Login" button
}
public void actionPerformed(ActionEvent e) {
char[] a = pass.getPassword();
String s = String.valueOf(a);
System.out.println(s);
if (s.equals("OOM")) {
new customer("OOM");
setVisible(false);
} else if (s.equals("Admin")) {
new admin();
setVisible(false);
} else {
JOptionPane.showMessageDialog(null, "Incorrect Password");
fn.setText("");
ln.setText("");
phoneNumber.setText(""); // Clear phone number field
email.setText(""); // Clear email field
pass.setText("");
}
}
public static void main(String[] args) {
if (!GraphicsEnvironment.isHeadless()) {
new Login("First Name", "Last Name");
}
}
}
*/