-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewReservation.java
More file actions
44 lines (37 loc) · 1.03 KB
/
ViewReservation.java
File metadata and controls
44 lines (37 loc) · 1.03 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
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class ViewReservation {
private HotelReservationSystem s;
public ViewReservation(HotelReservationSystem s)
{
JFrame jeff = new JFrame();
this.s = s;
JPanel panel = new JPanel();
for (Reservation r: s.getCurrentGuest().getReservations())
{
JLabel label = new JLabel(r.getRoomNumber() + " " + r.getStartDate() + " to " + r.getEndDate());
JButton button = new JButton("Cancel this reservation");
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
s.delReservation(r);
panel.remove(label);
panel.remove(button);
panel.revalidate();
panel.repaint();
}
});
panel.add(label);
panel.add(button);
}
jeff.add(panel);
jeff.setVisible(true);
jeff.setSize(500, 500);
}
}