Changed message list components to JPanels

This commit is contained in:
Kai S. K. Engelbart 2020-01-27 20:23:30 +01:00
parent 37a54303d3
commit df8eb4bac9

View File

@ -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<Message> {
@Override
public JComponent getListCellComponent(ComponentList<? extends Message> 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<Message> {
// 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("<html><p style=\"color:%s\"><b><small>%s</b></small><br><p style=\"color:%s\">%s :%s</html>",
//JLabel textLabel = new JLabel(text + ": " + state);
panel.add(new JLabel(String.format("<html><p style=\"color:%s\"><b><small>%s</b></small><br><p style=\"color:%s\">%s :%s</html>",
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;
}
}