package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import model.Message;
import view.MessageBoard;

public class MessageBoardController implements ActionListener{
	private Controller controller;
	
	public MessageBoardController(Controller controller) {
		this.controller = controller;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		MessageBoard messageBoard =(MessageBoard)((JButton)e.getSource()).getParent();
		//System.out.println("Send this message: "+messageBoard.getMessage()+" to: "+messageBoard.getUser().getUserName());
		String mess = messageBoard.getMessage();
		if(!mess.equals("")){
			System.out.println("in controller "+mess);
			Message messageToServet = new Message(messageBoard.getUser().getUserName(),mess);
			Message messageToDoc = new Message(controller.getModel().getAuthUser().getUserName(),mess);
			messageToDoc.printMessage(messageBoard.getUser().getDoc());
			controller.getServerHandler().sendMessage(messageToServet);
		}
	}

}

@@ -91,35 +91,132 @@
 er;%0A
-%0Aimport javax.swing.JButton
+import java.awt.event.KeyEvent;%0Aimport java.awt.event.KeyListener;%0A%0Aimport javax.swing.JButton;%0Aimport javax.swing.JTextArea
 ;%0A%0Ai
@@ -324,16 +324,29 @@
 Listener
+, KeyListener
 %7B%0A%09priva
@@ -371,17 +371,16 @@
 roller;%0A
-%09
 %0A%09public
@@ -468,264 +468,61 @@
 %09%7D%0A%09
-%0A%09@Override%0A%09public void actionPerformed(ActionEvent e) %7B%0A%09%09MessageBoard messageBoard =(MessageBoard)((JButton)e.getSource()).getParent();%0A%09%09//System.out.println(%22Send this message: %22+messageBoard.getMessage()+%22 to: %22+messageBoard.getUser().getUserName());
+private void sendMessage(MessageBoard messageBoard) %7B
 %0A%09%09S
@@ -945,10 +945,504 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09@Override%0A%09public void actionPerformed(ActionEvent e) %7B%0A%09%09MessageBoard messageBoard =(MessageBoard)((JButton)e.getSource()).getParent();%09%09%0A%09%09sendMessage(messageBoard);%0A%09%7D%0A%0A%0A%09@Override%0A%09public void keyPressed(KeyEvent e) %7B%0A%09%09if(e.getKeyCode() == KeyEvent.VK_ENTER)%7B%0A%09%09%09MessageBoard messageBoard = (MessageBoard)((JTextArea)e.getSource()).getParent();%09%09%0A%09%09%09sendMessage(messageBoard);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void keyReleased(KeyEvent e) %7B %7D%0A%0A%09@Override%0A%09public void keyTyped(KeyEvent e) %7B %7D%0A%0A
 %7D%0A

Update Client MesaggeBorad KeyListener