-
Notifications
You must be signed in to change notification settings - Fork 0
/
amOp1Pop.java
100 lines (79 loc) · 2.59 KB
/
amOp1Pop.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.company;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Objects;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
public class amOp1Pop extends JFrame {
protected HashMap<String, String> ausers = 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 user in the admin menu made with java swing
*<br>
* @param -
* @return
* @see -
* @author tsig-404
*/
public amOp1Pop(HashMap<String,String> us) {
this.ausers=us;
setTitle("Search User");
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("Username of the user:");
panel1.add(labelSearch);
textSearch = new JTextField("");
panel1.add(textSearch);
result = new JTextField("user:");
result.setEditable(false);
panel1.add(result);
add(panel1, BorderLayout.CENTER);
JPanel panel2 = new JPanel();
JButton search = new JButton("search user");
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 : ausers.keySet()) {
if (Objects.equals(i, name)) {
result.setText("This user exist");
found = true;
break;
}
}
if (found == false)
result.setText("This user doesnt exist");
}
}