Added HTML formatting to message list elements
This commit is contained in:
parent
78f9f4c883
commit
18a078475d
@ -1,6 +1,7 @@
|
|||||||
package envoy.client.ui;
|
package envoy.client.ui;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
@ -21,8 +22,7 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList<? extends Message> list, Message value, int index,
|
public Component getListCellRendererComponent(JList<? extends Message> list, Message value, int index,
|
||||||
boolean isSelected,
|
boolean isSelected, boolean cellHasFocus) {
|
||||||
boolean cellHasFocus) {
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
setBackground(list.getSelectionBackground());
|
setBackground(list.getSelectionBackground());
|
||||||
setForeground(list.getSelectionForeground());
|
setForeground(list.getSelectionForeground());
|
||||||
@ -31,11 +31,13 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
|
|||||||
setForeground(list.getForeground());
|
setForeground(list.getForeground());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable background rendering
|
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
|
||||||
setText(value.getContent().get(0).getText());
|
setText(String.format(
|
||||||
setFont(list.getFont());
|
"<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;
|
return this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user