Properly override updateItem method of list cells
This commit is contained in:
		@@ -28,7 +28,10 @@ public class ContactListCell extends ListCell<Contact> {
 | 
				
			|||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	protected void updateItem(Contact contact, boolean empty) {
 | 
						protected void updateItem(Contact contact, boolean empty) {
 | 
				
			||||||
		super.updateItem(contact, empty);
 | 
							super.updateItem(contact, empty);
 | 
				
			||||||
		if (!empty && contact != null) {
 | 
							if (empty || contact == null) {
 | 
				
			||||||
 | 
								setText(null);
 | 
				
			||||||
 | 
								setGraphic(null);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			// the infoLabel displays specific contact info, i.e. status of a user or amount
 | 
								// the infoLabel displays specific contact info, i.e. status of a user or amount
 | 
				
			||||||
			// of members in a group
 | 
								// of members in a group
 | 
				
			||||||
			Label infoLabel = null;
 | 
								Label infoLabel = null;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,10 +45,15 @@ public class MessageListCell extends ListCell<Message> {
 | 
				
			|||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	protected void updateItem(Message message, boolean empty) {
 | 
						protected void updateItem(Message message, boolean empty) {
 | 
				
			||||||
		super.updateItem(message, empty);
 | 
							super.updateItem(message, empty);
 | 
				
			||||||
		setGraphic(!empty && message != null ? new HBox(
 | 
							if(empty || message == null) {
 | 
				
			||||||
 | 
								setText(null);
 | 
				
			||||||
 | 
								setGraphic(null);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								setGraphic(new HBox(
 | 
				
			||||||
					new VBox(
 | 
										new VBox(
 | 
				
			||||||
					 new Label(dateFormat.format(message.getCreationDate())),
 | 
										 new Label(dateFormat.format(message.getCreationDate())),
 | 
				
			||||||
					 new Label(message.getText())),
 | 
										 new Label(message.getText())),
 | 
				
			||||||
					new Label("", new ImageView(statusImages.get(message.getStatus())))) : null);
 | 
										new Label("", new ImageView(statusImages.get(message.getStatus())))));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user