Added HTML formatting to message list elements

This commit is contained in:
Kai S. K. Engelbart 2019-10-23 05:49:15 +02:00
parent 78f9f4c883
commit 18a078475d

View File

@ -1,6 +1,7 @@
package envoy.client.ui;
import java.awt.Component;
import java.text.SimpleDateFormat;
import javax.swing.JLabel;
import javax.swing.JList;
@ -21,8 +22,7 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
@Override
public Component getListCellRendererComponent(JList<? extends Message> list, Message value, int index,
boolean isSelected,
boolean cellHasFocus) {
boolean isSelected, boolean cellHasFocus) {
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
@ -31,11 +31,13 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
setForeground(list.getForeground());
}
// Enable background rendering
setOpaque(true);
setText(value.getContent().get(0).getText());
setFont(list.getFont());
setText(String.format(
"<html><p style=\"color:#d2d235\"><b><small>%s</b></small><br><p style=\"color:white\">%s</html>",
new SimpleDateFormat("dd.MM.yyyy hh:mm ")
.format(value.getMetaData().getDate().toGregorianCalendar().getTime()),
value.getContent().get(0).getText()));
return this;
}