Skip to content

Commit 32a57f4

Browse files
committed
Added buttons for modifying profile or searching for users to the appscreen ui
1 parent f5741e1 commit 32a57f4

File tree

5 files changed

+27
-52
lines changed

5 files changed

+27
-52
lines changed

src/main/java/Main.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/main/java/screens/Profile_screen/UserSearchUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class UserSearchUI {
1515
public UserSearchUI() {
1616
final JFrame frame = new JFrame();
1717
frame.setSize(300, 100);
18-
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
18+
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
1919
frame.setLayout(new FlowLayout());
2020

2121
final JTextField field = new JTextField("Enter a username");

src/main/java/screens/appscreen/AppScreen.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
import entities.chat.PrivateChatfactory;
66
import interface_adapters.appscreen.AppScreenPresenter;
77
import interface_adapters.appscreen.Refresh;
8+
import screens.Profile_screen.UserSearchUI;
89
import screens.chat_screen.ChatController;
910
import screens.chat_screen.ChatView;
11+
import screens.profile_update_screen.UserModificationUI;
1012
import use_cases.appscreen.*;
1113
import use_cases.chat_initiation_use_case.ChatInputBoundry;
1214
import use_cases.chat_initiation_use_case.ChatInteractor;
@@ -26,8 +28,8 @@ public class AppScreen implements AppScreenPresenter, Refresh {
2628

2729
/**
2830
Create an AppScreen object
29-
@param chats This is a list of chats given by the user (the list will always come as sorted with the
30-
most recent chats at the end of the list)
31+
@param chats This is a list o most recent chats at the end of the list)
32+
f chats given by the user (the list will always come as sorted with the
3133
*/
3234
public AppScreen(String currentUsername, ArrayList<Chat> chats) {
3335
this.currentUsername = currentUsername;
@@ -47,6 +49,24 @@ public AppScreen(String currentUsername, ArrayList<Chat> chats) {
4749
addPrivateChat.setPreferredSize(new Dimension(40, 30));
4850
addGroupChat.setPreferredSize(new Dimension(40, 30));
4951

52+
// menu panel containing the buttons for searching for users or accessing profile settings
53+
JPanel menuPanel = new JPanel();
54+
menuPanel.setLayout(new GridLayout(1,2));
55+
56+
JButton searchUsers = new JButton("Search Users");
57+
JButton profileSettings = new JButton("Profile Settings");
58+
59+
searchUsers.setPreferredSize(new Dimension(40, 30));
60+
profileSettings.setPreferredSize(new Dimension(30, 30));
61+
62+
63+
// adding the action listeners for the Search Users button
64+
searchUsers.addActionListener(e -> new UserSearchUI());
65+
66+
// adding the action listeners for the Profile Settings button
67+
profileSettings.addActionListener(e -> new UserModificationUI());
68+
69+
5070
// adding the action listeners for the +private-chat and +group-chat buttons
5171
addPrivateChat.addActionListener(e -> {
5272
PrivateChatfactory privateChatfactory = new CommonPrivatechat();
@@ -64,7 +84,10 @@ public AppScreen(String currentUsername, ArrayList<Chat> chats) {
6484

6585
topPanel.add(addPrivateChat);
6686
topPanel.add(addGroupChat);
87+
menuPanel.add(searchUsers);
88+
menuPanel.add(profileSettings);
6789
jFrame.add(topPanel, BorderLayout.NORTH);
90+
jFrame.add(menuPanel, BorderLayout.SOUTH);
6891

6992
this.chats = chats;
7093
openScreen();

src/main/java/screens/profile_update_screen/UserModificationUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public UserModificationUI() {
1717
final JFrame frame = new JFrame();
1818
frame.setSize(500, 300);
1919

20-
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
20+
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
2121
frame.setLayout(new FlowLayout());
2222

2323
// Field for username

user_accounts

317 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)