From 5ecda78cf12edda2997e226369b9c748c7805acd Mon Sep 17 00:00:00 2001 From: kske Date: Mon, 27 Jan 2020 20:23:30 +0100 Subject: [PATCH] Changed message list components to JPanels --- .../envoy/client/ui/MessageListRenderer.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index 51cbbd5..11312d1 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; import javax.swing.JComponent; import javax.swing.JLabel; +import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import envoy.client.Settings; @@ -26,19 +27,17 @@ public class MessageListRenderer implements ComponentListCellRenderer { @Override public JComponent getListCellComponent(ComponentList list, Message value, boolean isSelected) { - final JLabel label = new JLabel(); + final JPanel panel = new JPanel(); if (isSelected) { - label.setBackground(Color.DARK_GRAY); - label.setForeground(Color.RED); + panel.setBackground(Color.DARK_GRAY); + panel.setForeground(Color.RED); // setBackground(list.getSelectionBackground()); // setForeground(list.getSelectionForeground()); } else { - label.setBackground(list.getBackground()); - label.setForeground(list.getForeground()); + panel.setBackground(list.getBackground()); + panel.setForeground(list.getForeground()); } - label.setOpaque(true); - // TODO: Handle message attachments final String text = value.getText(); @@ -51,16 +50,18 @@ public class MessageListRenderer implements ComponentListCellRenderer { // Getting the DateColor in the Chat of the current theme String dateColor = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getDateColorChat().toHex(); - label.setText(String.format("

%s

%s :%s", + //JLabel textLabel = new JLabel(text + ": " + state); + + panel.add(new JLabel(String.format("

%s

%s :%s", dateColor, date, textColor, text, - state)); + state))); // Define some space to the components above and below - label.setBorder(new EmptyBorder(0, 0, 15, 0)); + panel.setBorder(new EmptyBorder(0, 0, 15, 0)); - return label; + return panel; } } \ No newline at end of file