-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewBusesFrame.java
More file actions
115 lines (90 loc) · 3.63 KB
/
Copy pathViewBusesFrame.java
File metadata and controls
115 lines (90 loc) · 3.63 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
package campusComplaints;
import javax.swing.*;
import java.awt.*;
public class ViewBusesFrame extends JFrame {
String RollNumber;
ViewBusesFrame(String RollNumber) {
this.RollNumber = RollNumber;
this.setLayout(null);
this.setVisible(true);
this.setBounds(800, 300, 500, 800);
// ================= HEADER =================
JPanel header = new JPanel(null);
header.setBounds(0, 0, 500, 53);
header.setBackground(new Color(173, 216, 230));
this.add(header);
Font hf = new Font("Tahoma", Font.BOLD, 13);
JLabel hBus = new JLabel("BUS NO");
hBus.setBounds(20, 15, 80, 25);
hBus.setFont(hf);
JLabel hFrom = new JLabel("FROM");
hFrom.setBounds(110, 15, 100, 25);
hFrom.setFont(hf);
JLabel hTo = new JLabel("TO");
hTo.setBounds(230, 15, 100, 25);
hTo.setFont(hf);
JLabel hTime = new JLabel("TIME");
hTime.setBounds(320, 15, 60, 25);
hTime.setFont(hf);
header.add(hBus);
header.add(hFrom);
header.add(hTo);
header.add(hTime);
// ================= PANELS =================
int y = 53;
Color[] colors = {
new Color(255,204,204), new Color(204,255,204),
new Color(255,255,204), new Color(255,229,204),
new Color(204,255,255), new Color(255,204,229),
new Color(230,230,250), new Color(224,255,255),
new Color(240,248,255), new Color(255,239,213),
new Color(232,232,232), new Color(245,245,220),
new Color(255,228,225), new Color(224,255,224)
};
String[][] data = {
{"LN-101", "LNMIIT", "AjmeriGate", "07:00 AM"},
{"LN-102", "AjmeriGate", "LNMIIT", "08:00 AM"},
{"LN-103", "LNMIIT", "RajaPark", "10:00 AM"},
{"LN-104", "RajaPark", "LNMIIT", "12:00noon"},
{"LN-105", "LNMIIT", "RajaPark", "1:00 PM"},
{"LN-106", "RajaPark ", "LNMIIT", "03:00 PM"},
{"LN-107", "LNMIIT", "RajaPark", "04:00 PM"},
{"LN-108", "LNMIIT", "AjmeriGate", "04:30 PM"},
{"LN-109", "RajaPark", "LNMIIT", "05:15 PM"},
{"LN-110", "LNMIIT", "RajaPark", "05:00 PM"},
{"LN-111", "LNMIIT", "AjmeriGate", "06:00 PM"},
{"LN-112", "AjmeriGate", "LNMIIT", "08:15 PM"},
{"LN-113", "RajaPark", "LNMIIT", "09:00 PM"},
{"LN-114", "AjmeriGate", "LNMIIT", "09:00 PM"}
};
for (int i = 0; i < 14; i++) {
JPanel p = new JPanel(null);
p.setBounds(0, y, 500, 53);
p.setBackground(colors[i]);
JLabel bus = new JLabel(data[i][0]);
bus.setBounds(20, 15, 80, 25);
JLabel from = new JLabel(data[i][1]);
from.setBounds(110, 15, 100, 25);
JLabel to = new JLabel(data[i][2]);
to.setBounds(230, 15, 100, 25);
JLabel time = new JLabel(data[i][3]);
time.setBounds(320, 15, 60, 25);
String busNo = data[i][0]; // LN-101, LN-102, etc.
JButton book = new JButton("Book Seat");
book.addActionListener(e -> {
new Bus(busNo,RollNumber);
});
book.setBounds(380, 10, 100, 30);
p.add(bus);
p.add(from);
p.add(to);
p.add(time);
p.add(book);
this.add(p);
y += 53;
}
}
public static void main(String[] args) {
new ViewBusesFrame("24ucs100");
}
}