diff --git a/src/main/java/envoy/client/ui/MessageListRenderer.java b/src/main/java/envoy/client/ui/MessageListRenderer.java index 11312d1..c038e39 100644 --- a/src/main/java/envoy/client/ui/MessageListRenderer.java +++ b/src/main/java/envoy/client/ui/MessageListRenderer.java @@ -1,11 +1,9 @@ package envoy.client.ui; +import java.awt.Dimension; import java.text.SimpleDateFormat; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.border.EmptyBorder; +import javax.swing.*; import envoy.client.Settings; import envoy.client.ui.list.ComponentList; @@ -31,6 +29,7 @@ public class MessageListRenderer implements ComponentListCellRenderer { if (isSelected) { panel.setBackground(Color.DARK_GRAY); panel.setForeground(Color.RED); + // TODO: Selection // setBackground(list.getSelectionBackground()); // setForeground(list.getSelectionForeground()); } else { @@ -50,8 +49,6 @@ 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(); - //JLabel textLabel = new JLabel(text + ": " + state); - panel.add(new JLabel(String.format("

%s

%s :%s", dateColor, date, @@ -59,8 +56,14 @@ public class MessageListRenderer implements ComponentListCellRenderer { text, state))); - // Define some space to the components above and below - panel.setBorder(new EmptyBorder(0, 0, 15, 0)); + // Define some space to the messages below + panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 0, 15, 0), BorderFactory.createEtchedBorder())); + + // Define a maximum height of 50px + Dimension size = new Dimension(list.getWidth() - 25, 50); + panel.setMaximumSize(size); + panel.setMinimumSize(size); + panel.setPreferredSize(size); return panel; } diff --git a/src/main/java/envoy/client/ui/list/ComponentList.java b/src/main/java/envoy/client/ui/list/ComponentList.java index 5b2ea45..8cbf2db 100644 --- a/src/main/java/envoy/client/ui/list/ComponentList.java +++ b/src/main/java/envoy/client/ui/list/ComponentList.java @@ -1,9 +1,6 @@ package envoy.client.ui.list; -import java.awt.Dimension; - import javax.swing.BoxLayout; -import javax.swing.JComponent; import javax.swing.JPanel; /** @@ -77,12 +74,7 @@ public class ComponentList extends JPanel { * @since Envoy v0.3-alpha */ void add(E elem) { - JComponent c = renderer.getListCellComponent(this, elem, false); - Dimension size = new Dimension(getWidth(), 50); - c.setMaximumSize(size); - c.setMinimumSize(size); - c.setPreferredSize(size); - add(c); + add(renderer.getListCellComponent(this, elem, false)); } /**