@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getComponent().getName().equals("chatline")) {
			inputChat.setText("");
		} else if (e.getComponent().getName().equals("username")) {
			userName.setText("");
		} else if (e.getComponent().getName().equals("audio-toggle")) {
			JToggleButton temp;
			temp = (JToggleButton) e.getComponent();
			boolean isSelected;
			if (temp.isSelected()) {
				isSelected = temp.isSelected();
				AudioFormat format = new AudioFormat(8000, 8, 1, true, true);
				TargetDataLine line;
				DataLine.Info info = new DataLine.Info(TargetDataLine.class,
						format); // format is an AudioFormat object
				if (!AudioSystem.isLineSupported(info)) {
					// Handle the error ...
				}
				// Obtain and open the line.
				try {
					line = (TargetDataLine) AudioSystem.getLine(info);
					line.open(format);

					ByteArrayOutputStream out = new ByteArrayOutputStream();
					int numBytesRead;
					byte[] data = new byte[line.getBufferSize() / 5];

					// Begin audio capture.
					line.start();

					// Here, stopped is a global boolean set by another thread.
//					while (isSelected) {
						// Read the next chunk of data from the TargetDataLine.
						numBytesRead = line.read(data, 0, data.length);
						// Save this chunk of data.
						out.write(data, 0, numBytesRead);
						System.out.println("numBytesRead: "+numBytesRead);
						byte audio[] = out.toByteArray();
						System.out.println("bytes length: "+audio.length);
						
//						THIS IS TO PLAY THE SOUND
						
//						byte audio[] = out.toByteArray();
						  InputStream input = new ByteArrayInputStream(audio);
						  AudioInputStream ais = new AudioInputStream(input, 
						    format, audio.length / format.getFrameSize());
						  DataLine.Info info1 = new DataLine.Info(
			                         SourceDataLine.class, format);
			  SourceDataLine line1 = 
			             (SourceDataLine)AudioSystem.getLine(info1);
			  line1.open(format);
			  line1.start();
			  int bufferSize = (int) format.getSampleRate() 
					    * format.getFrameSize();
					  byte buffer[] = new byte[bufferSize];

					  int count;
					  try {
						while ((count = ais.read(buffer, 0, buffer.length)) != -1) {
						    if (count > 0) {
						      line1.write(buffer, 0, count);
						    }
						  }
					} catch (IOException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					  line1.drain();
					  line1.close();
						
//					}
				} catch (LineUnavailableException ex) {
					// Handle the error ...
				}

				System.out.println("YOU HAVE SELECTED THE BUTTON!");
				// this means that the button is selected now and the audio
				// should be recorded!
			} else {
				isSelected = temp.isSelected();
				System.out.println("DESELECT!");
				// this means the button is deselected so the audio should stop!
			}

		}

	}