-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamOp2Pop.java
86 lines (67 loc) · 2.23 KB
/
amOp2Pop.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
83
84
85
86
package com.company;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Objects;
public class amOp2Pop extends JFrame{
protected HashMap<String, String> rented = new HashMap<String, String>();
private JTextField textSearch;
private JLabel labelSearch;
private JTextField result;
/**
* <p>
*this is the gui and code for the choice to search a reservation in the admin menu made with java swing
*<br>
* @param -
* @return
* @see -
* @author tsig-404
*/
public amOp2Pop(HashMap<String,String> rn) {
this.rented=rn;
setTitle("Search reservation");
setLocationRelativeTo(null);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(true);
JPanel panel1 = new JPanel();
setSize(400, 300);
GridLayout layout = new GridLayout(4, 2, 2, 2);
panel1.setLayout(layout);
labelSearch = new JLabel("write the name of the room:");
panel1.add(labelSearch);
textSearch = new JTextField("");
panel1.add(textSearch);
result = new JTextField("the room is:");
result.setEditable(false);
panel1.add(result);
add(panel1, BorderLayout.CENTER);
JPanel panel2 = new JPanel();
JButton search = new JButton("search reservation");
search.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
csearch();
}
});
panel2.add(search);
add(panel2, BorderLayout.PAGE_END);
csearch();
pack();
setVisible(true);
}
private void csearch() {
String name = new String(textSearch.getText());
boolean found=false;
for (String i : rented.keySet()) {
if (Objects.equals(i, name)) {
result.setText("The room is rented");
found = true;
break;
}
}
if (found == false)
result.setText("The room isnt rented");
}
}