private void sendMessage(PaneTab selectedTab) {
		if (!selectedTab.getMessageField().getText().isEmpty()) {
			String message = selectedTab.getMessageField().getText();
			if (this.view.tabs.getSelectedIndex() == 0) {
				// Public message
				int maxPublicMessageLength = this.client.MAX_PACKET_SIZE
						- this.client.GENERAL_HEADER_SIZE
						- this.client.PUBLIC_CHAT_HEADER_SIZE;
				int it = 0;
				while (it + maxPublicMessageLength < message.length()) {
					client.sendPublicMessage(message.substring(it, it
							+ maxPublicMessageLength - 1));
					it = it + maxPublicMessageLength;
				}

				client.sendPublicMessage(message.substring(it, message.length()));

			} else {
				// private message
				int maxPrivateMessageLength = this.client.MAX_PACKET_SIZE
						- this.client.GENERAL_HEADER_SIZE
						- this.client.PRIVATE_CHAT_HEADER_SIZE;

				int it = 0;
				while (it + maxPrivateMessageLength < message.length()) {
					client.sendPrivateMessage(
							message.substring(it, it + maxPrivateMessageLength
									- 1), selectedTab.getAddress());
					it = it + maxPrivateMessageLength;
				}
				client.sendPrivateMessage(
						message.substring(it, message.length()),
						selectedTab.getAddress());
				this.view.addMessage(this.client.getOwnUser().getIP(),
						selectedTab.getAddress(), message,
						Timestamp.getCurrentTimeAsLong(), true);
			}
		}
		selectedTab.getMessageField().setText("");
	}