@Override
	public void actionPerformed(ActionEvent e) {
		//Set ip address
		if (e.getSource() == ipSetButton) {
			serverAddress = new InetSocketAddress(ipField.getText().trim(), defaultPort);
			local.println("IP Address set to: " + serverAddress);
			log.setCaretPosition(log.getDocument().getLength());
		}
		//Start sending random fruit
		if (e.getSource() == startButton) {
			local.println("Sending random fruit...");
			log.setCaretPosition(log.getDocument().getLength());
			if (generator == null) {
				generator = new RandomFruitGenerator(serverAddress, local);
			}
			generator.start();
		}
		//Pause sending random fruit
		if (e.getSource() == pauseButton) {
			if (generator != null) {
				generator.pause();
				local.println("Paused");
				log.setCaretPosition(log.getDocument().getLength());
			}
		}
		//Stop sending random fruit
		if (e.getSource() == stopButton) {
			if (generator != null) {
				generator.stop();	
				local.println("Stopping fruit sending thread");
				log.setCaretPosition(log.getDocument().getLength());
			}
			generator = null;
		}
		log.setCaretPosition(log.getDocument().getLength());
	}