public void setUnit(Unit unit, Player unitOwner, ActionListener actionListener, boolean unitActive) 
	{
		if (unit == null) {
			setUnitUIVisible(false);
			nameLabel.setText(""); //If the panel labelled "unit" is empty, it should be clear that no unit is selected.
		} else {
			setUnitUIVisible(true);
			
			nameLabel.setText(" " + unit.getName()); //Add a space before the name since it looks better.
			if (unitOwner != null) {
				factionLabel.setText(" of the " + unitOwner.getTheme().getFactionName());
			} else {
				factionLabel.setText(" (independant) ");
			}
			
			portraitPanel.removeAll();
			try {
				portraitPanel.add(new JLabel("", new ImageIcon(unit.getImage()), JLabel.CENTER));
			} catch (IllegalArgumentException exception) {
				exception.printStackTrace();
			} catch (IOException exception) {
				exception.printStackTrace();
			}
			
			displayHealth(unit);
			displayMove(unit);
			
			statusPanel.removeAll();
			if (unit.getStatuses().isEmpty()) {
				JLabel normalLabel = new JLabel();
				normalLabel.setText("Status: NORMAL");
				statusPanel.add(normalLabel);
			} else {
				for (UnitStatus status : unit.getStatuses()) {
					addStatus(status.getType(), status.getRemainingDuration());
				}
			}
			
			//Make the ability panel exactly big enough for all the abilities.
			abilitiesPanel.removeAll();
			abilitiesPanel.setPreferredSize(new Dimension(AbilityPanel.WIDTH, unit.getAbilities().size()*AbilityPanel.HEIGHT));
			for (Ability ability : unit.getAbilities()) {
				abilitiesPanel.add(new AbilityPanel(ability, actionListener, unitActive));
			}
			
			revalidate(); //Always validate the entire panel when its components change.
			repaint();
		}
	}