Repository navigation
Expand file tree
/
Copy pathPickUp.java
More file actions
142 lines (119 loc) · 4.55 KB
/
Copy pathPickUp.java
File metadata and controls
142 lines (119 loc) · 4.55 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
package Hotel.Management.System;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class PickUp extends JFrame {
public PickUp() {
JPanel panel = new JPanel();
panel.setBackground(new Color(3, 45, 48));
panel.setBounds(5, 5, 790, 590);
panel.setLayout(null);
add(panel);
JLabel pus = new JLabel("Pick Up Service");
pus.setBounds(90, 11, 160, 25);
pus.setForeground(Color.WHITE);
pus.setFont(new Font("Tahoma", Font.BOLD, 20));
panel.add(pus);
JLabel TOC = new JLabel("Type of Car");
TOC.setBounds(32, 97, 89, 14);
TOC.setForeground(Color.WHITE);
TOC.setFont(new Font("Tahoma", Font.PLAIN, 14));
panel.add(TOC);
Choice carChoice = new Choice();
carChoice.setBounds(123, 94, 150, 25);
panel.add(carChoice);
try {
connection c = new connection();
String q = "SELECT DISTINCT car_name FROM driver";
ResultSet rs = c.statement.executeQuery(q);
while (rs.next()) {
carChoice.add(rs.getString("car_name"));
}
} catch (Exception e) {
e.printStackTrace();
}
JTable table = new JTable();
table.setBounds(10, 233, 760, 250);
table.setBackground(new Color(3, 45, 48));
table.setForeground(Color.WHITE);
panel.add(table);
try {
connection c = new connection();
String q = "SELECT * FROM driver";
ResultSet resultSet = c.statement.executeQuery(q);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
} catch (Exception e) {
e.printStackTrace();
}
JLabel name = new JLabel("Name");
name.setBounds(24, 208, 46, 14);
name.setForeground(Color.WHITE);
panel.add(name);
JLabel age = new JLabel("Age");
age.setBounds(165, 208, 46, 14);
age.setForeground(Color.WHITE);
panel.add(age);
JLabel gender = new JLabel("Gender");
gender.setBounds(264, 208, 46, 14);
gender.setForeground(Color.WHITE);
panel.add(gender);
JLabel company = new JLabel("Company");
company.setBounds(366, 208, 100, 14);
company.setForeground(Color.WHITE);
panel.add(company);
JLabel carName = new JLabel("Car Name");
carName.setBounds(486, 208, 100, 14);
carName.setForeground(Color.WHITE);
panel.add(carName);
JLabel available = new JLabel("Available");
available.setBounds(600, 208, 100, 14);
available.setForeground(Color.WHITE);
panel.add(available);
JLabel location = new JLabel("Location");
location.setBounds(700, 208, 100, 14);
location.setForeground(Color.WHITE);
panel.add(location);
JButton display = new JButton("Display");
display.setBounds(200, 500, 120, 30);
display.setBackground(Color.BLACK);
display.setForeground(Color.WHITE);
panel.add(display);
display.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String selectedCar = carChoice.getSelectedItem();
String query = "SELECT * FROM driver WHERE car_name = '" + selectedCar + "'";
try {
connection c = new connection();
ResultSet resultSet = c.statement.executeQuery(query);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
} catch (SQLException ex) {
ex.printStackTrace();
}
}
});
JButton back = new JButton("Back");
back.setBounds(420, 500, 120, 30);
back.setBackground(Color.BLACK);
back.setForeground(Color.WHITE);
panel.add(back);
back.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
setLayout(null);
setSize(800, 600);
setLocation(500, 100);
setVisible(true);
}
public static void main(String[] args) {
new PickUp();
}
}