Repository navigation
Expand file tree
/
Copy pathRoom.java
More file actions
83 lines (68 loc) · 2.58 KB
/
Copy pathRoom.java
File metadata and controls
83 lines (68 loc) · 2.58 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
package Hotel.Management.System;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Room extends JFrame {
JTable table;
JButton back;
Room() {
JPanel panel = new JPanel();
panel.setBounds(5, 5, 890, 590);
panel.setBackground(new Color(3, 45, 48));
panel.setLayout(null);
add(panel);
// Room image
ImageIcon imageIcon = new ImageIcon(ClassLoader.getSystemResource("icon/roomm.png"));
Image image = imageIcon.getImage().getScaledInstance(200, 200, Image.SCALE_DEFAULT);
JLabel label = new JLabel(new ImageIcon(image));
label.setBounds(600, 200, 200, 200);
panel.add(label);
// Table
table = new JTable();
table.setBounds(10, 40, 550, 400);
table.setBackground(new Color(3, 45, 48));
table.setForeground(Color.WHITE);
table.setFont(new Font("Tahoma", Font.PLAIN, 14));
table.setRowHeight(25);
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setBounds(10, 40, 550, 400);
panel.add(scrollPane);
// --- DATABASE CONNECTION ---
try {
Connection c = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/HotelMS", "chirayu", "chirayu");
Statement stmt = c.createStatement();
// Correct column order with aliases
String RoomInfo = "SELECT roomnumber AS 'Room No.', " +
"availability AS 'Availability', " +
"cleaningstatus AS 'Clean Status', " +
"price AS 'Price', " +
"bedtype AS 'Bed Type' " +
"FROM room";
ResultSet resultSet = stmt.executeQuery(RoomInfo);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
} catch (Exception e) {
e.printStackTrace();
}
// Back button
back = new JButton("BACK");
back.setBackground(Color.BLACK);
back.setForeground(Color.WHITE);
back.setBounds(200, 500, 120, 30);
panel.add(back);
back.addActionListener(e -> setVisible(false));
// Frame settings
setUndecorated(true);
setLayout(null);
setLocation(500, 100);
setSize(900, 600);
setVisible(true);
}
public static void main(String[] args) {
new Room();
}
}