-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbookingPage.java
82 lines (74 loc) · 2.78 KB
/
bookingPage.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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class bookingPage extends JFrame {
ArrayList<tickets> ticketlist = new ArrayList<tickets>();
JLabel identityNo = new JLabel("Identity Number");
JTextField ino = new JTextField();
JLabel name = new JLabel("Name");
JTextField namefield = new JTextField();
JLabel to = new JLabel("To:");
JTextField tofeild = new JTextField();
JLabel from = new JLabel("From");
JTextField fromfield = new JTextField();
JButton search = new JButton("Search flights");
Container pane = getContentPane();
JButton book = new JButton("Book");
bookingPage(String title) {
super(title);
book.setBackground(new Color(114,212,232));
book.setForeground(Color.BLUE);
search.setBackground(new Color(114,212,232));
search.setForeground(Color.BLUE);
identityNo.setForeground(Color.WHITE);
name.setForeground(Color.WHITE);
to.setForeground(Color.WHITE);
from.setForeground(Color.WHITE);
pane.setLayout(new GridLayout(5, 2));
pane.add(identityNo);
pane.add(ino);
pane.add(name);
pane.add(namefield);
pane.add(to);
pane.add(tofeild);
pane.add(from);
pane.add(fromfield);
pane.add(search, BorderLayout.CENTER);
pane.add(book);
pane.setBackground(new Color(60,52,76));
setMinimumSize(new Dimension(500, 600));
setSize(500, 600);
listener l = new listener();
book.addActionListener(l);
search.addActionListener(l);
setVisible(true);
}
class listener implements ActionListener {
public void actionPerformed(ActionEvent event) {
if (event.getSource() == book) {
if (ino.getText().length() != 0 && namefield.getText().length() != 0 && tofeild.getText().length() != 0
&& fromfield.getText().length() != 0) {
SwingUtilities.invokeLater(() -> new MakePaymentPage());
} else {
JOptionPane.showMessageDialog(null, "All fields are mandatory!", "Airlines", 1);
}
} else if (event.getSource() == search) {
new searchFlight();
}
}
}
private void openFile(String filename) {
try {
File file = new File(filename);
Desktop.getDesktop().open(file);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new bookingPage("Book Flights");
}
}