Changed bgc of testArea and played on pref size of list and scrollPane

This commit is contained in:
DieGurke 2020-03-17 12:11:59 +01:00
parent 2de64956e4
commit ea75636e7f
2 changed files with 4 additions and 3 deletions

View File

@ -133,11 +133,12 @@ public class ChatWindow extends JFrame {
// updates list elements when list is resized // updates list elements when list is resized
@Override @Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
messageList.synchronizeModel();
var prefSize = e.getComponent().getPreferredSize(); var prefSize = e.getComponent().getPreferredSize();
e.getComponent().setPreferredSize(prefSize);
messageList.synchronizeModel();
messageList.setMinimumSize(new Dimension(prefSize.width, 0)); messageList.setMinimumSize(new Dimension(prefSize.width, 0));
messageList.setMaximumSize(new Dimension(prefSize.width, Integer.MAX_VALUE)); messageList.setMaximumSize(new Dimension(prefSize.width, Integer.MAX_VALUE));
messageList.setPreferredSize(new Dimension(prefSize.width, messageList.getPreferredSize().height)); messageList.setPreferredSize(new Dimension(prefSize.width, (int) messageList.getPreferredSize().getHeight()));
} }
}); });
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

View File

@ -91,7 +91,7 @@ public class MessageListRenderer implements ComponentListCellRenderer<Message> {
messageTextArea.setWrapStyleWord(true); messageTextArea.setWrapStyleWord(true);
messageTextArea.setForeground(theme.getMessageTextColor()); messageTextArea.setForeground(theme.getMessageTextColor());
messageTextArea.setAlignmentX(0.5f); messageTextArea.setAlignmentX(0.5f);
messageTextArea.setBackground(Color.RED); messageTextArea.setBackground(theme.getCellColor());
messageTextArea.setEditable(false); messageTextArea.setEditable(false);
var font = new Font("Arial", Font.PLAIN, 14); var font = new Font("Arial", Font.PLAIN, 14);
messageTextArea.setFont(font); messageTextArea.setFont(font);