Skip to content

Commit f5741e1

Browse files
committed
Created a main menu for SOLID Chat
1 parent e761c06 commit f5741e1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/main/java/Main.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import screens.Profile_screen.UserSearchUI;
2+
import screens.profile_update_screen.UserModificationUI;
3+
import javax.swing.*;
4+
import java.awt.*;
5+
import java.util.Objects;
6+
7+
8+
/**
9+
* Provides the main appl UI.
10+
*/
11+
public class Main {
12+
public static void main(String[] args) {
13+
final JFrame f = new JFrame();
14+
f.setSize(400, 200);
15+
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
16+
f.setLayout(new FlowLayout());
17+
18+
// to select feature that user wants to change
19+
JLabel lbl = new JLabel("<html>Select what you would like to do:</html>");
20+
lbl.setVisible(true);
21+
lbl.setBounds(10, 25, 100, 25);
22+
String[] choices = {"Search for users", "Modify my profile"};
23+
final JComboBox<String> cb = new JComboBox<>(choices);
24+
25+
26+
JButton btn = new JButton("OK");
27+
28+
btn.addActionListener(e -> {
29+
String feature = Objects.requireNonNull(cb.getSelectedItem()).toString();
30+
switch (feature) {
31+
case "Search for users":
32+
new UserSearchUI();
33+
break;
34+
case "Modify my profile":
35+
new UserModificationUI();
36+
break;
37+
}
38+
});
39+
40+
f.setTitle("SOLID Chat main menu");
41+
f.add(lbl);
42+
f.add(cb);
43+
f.add(btn);
44+
f.setVisible(true);
45+
46+
}
47+
}
48+

0 commit comments

Comments
 (0)