Changed message list components to JPanels
This commit is contained in:
		| @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; | |||||||
|  |  | ||||||
| import javax.swing.JComponent; | import javax.swing.JComponent; | ||||||
| import javax.swing.JLabel; | import javax.swing.JLabel; | ||||||
|  | import javax.swing.JPanel; | ||||||
| import javax.swing.border.EmptyBorder; | import javax.swing.border.EmptyBorder; | ||||||
|  |  | ||||||
| import envoy.client.Settings; | import envoy.client.Settings; | ||||||
| @@ -26,19 +27,17 @@ public class MessageListRenderer implements ComponentListCellRenderer<Message> { | |||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public JComponent getListCellComponent(ComponentList<? extends Message> list, Message value, boolean isSelected) { | 	public JComponent getListCellComponent(ComponentList<? extends Message> list, Message value, boolean isSelected) { | ||||||
| 		final JLabel label = new JLabel(); | 		final JPanel panel = new JPanel(); | ||||||
| 		if (isSelected) { | 		if (isSelected) { | ||||||
| 			label.setBackground(Color.DARK_GRAY); | 			panel.setBackground(Color.DARK_GRAY); | ||||||
| 			label.setForeground(Color.RED); | 			panel.setForeground(Color.RED); | ||||||
| 			// setBackground(list.getSelectionBackground()); | 			// setBackground(list.getSelectionBackground()); | ||||||
| 			// setForeground(list.getSelectionForeground()); | 			// setForeground(list.getSelectionForeground()); | ||||||
| 		} else { | 		} else { | ||||||
| 			label.setBackground(list.getBackground()); | 			panel.setBackground(list.getBackground()); | ||||||
| 			label.setForeground(list.getForeground()); | 			panel.setForeground(list.getForeground()); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		label.setOpaque(true); |  | ||||||
|  |  | ||||||
| 		// TODO: Handle message attachments | 		// TODO: Handle message attachments | ||||||
|  |  | ||||||
| 		final String	text	= value.getText(); | 		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 | 		// Getting the DateColor in the Chat of the current theme | ||||||
| 		String dateColor = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getDateColorChat().toHex(); | 		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, | 				dateColor, | ||||||
| 				date, | 				date, | ||||||
| 				textColor, | 				textColor, | ||||||
| 				text, | 				text, | ||||||
| 				state)); | 				state))); | ||||||
|  |  | ||||||
| 		// Define some space to the components above and below | 		// 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; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user