Skip to content

Commit 5e93e5e

Browse files
committed
Made changes to AppScreen's scroll frame
1 parent 4913eae commit 5e93e5e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/appscreen/AppScreen.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ public void actionPerformed(ActionEvent e) {
9595
}
9696

9797
jPanel.setAlignmentY(Component.CENTER_ALIGNMENT);
98-
jPanel.setPreferredSize(new Dimension(100, 500));
99-
jPanel.setMaximumSize(new Dimension(100, 500));
98+
99+
// set height of panel to appropriate size based on the number of chats
100+
jPanel.setPreferredSize(new Dimension(100, 60 * this.chats.size()));
100101
jPanel.setBorder(BorderFactory.createTitledBorder("My Chats"));
101102

102103

@@ -115,7 +116,8 @@ private void scrollableChats(JPanel jPanel) {
115116
JScrollPane scrollFrame = new JScrollPane(jPanel);
116117
jScrollPane = scrollFrame;
117118
scrollFrame.setPreferredSize(new Dimension( 200,500));
118-
jFrame.add(scrollFrame);
119+
scrollFrame. getVerticalScrollBar().setUnitIncrement(5);
120+
jFrame.getContentPane().add(scrollFrame);
119121
}
120122

121123

@@ -147,7 +149,7 @@ public void updateChatOrder(Chat chat){
147149

148150
/**
149151
* Add a new chat to the screen, if the chat already exists (i.e. there exists a chat with the
150-
* same ID, do nothing.
152+
* same ID, do nothing)
151153
* @param chat The new chat to be added
152154
*/
153155
public void addNewChat(Chat chat){

0 commit comments

Comments
 (0)