public void actionPerformed(ActionEvent e) {
		String command = e.getActionCommand();
		String JSONtext = "";
		switch (command) {
		case "chatmessage":  //JTextField
			try {
				JSONtext = enc.encode(new Message(lg.chatgui.field.getText(), ""));
				lg.chatgui.field.setText("");
			} catch (JSONException e1) {
				e1.printStackTrace();
			}
			break;

		case "joinbutton":
			try {
				String players = (String) lg.jt.getModel().getValueAt(lg.jt.getSelectedRow(),1);
				
				if (!(players.charAt(0) == players.charAt(2))) {
				JSONtext = enc.encode(new JoinMessage((String)lg.jt.getModel().getValueAt(lg.jt.getSelectedRow(),3)));
				} else {
					JOptionPane.showMessageDialog(null, "Room is full!", "Warning", JOptionPane.ERROR_MESSAGE);
				}
			} catch (JSONException e1) {
				e1.printStackTrace();
			}
			break;
			
		case "createbutton":
			try {
				JSONtext = enc.encode(new CreateGameMessage(lg.createList.getSelectedValue(), 2 , this.userName));
			} catch (JSONException e1) {
				e1.printStackTrace();
			}
			break;
			
		case "refreshbutton":		
			try {
				JSONtext = enc.encode(new RefreshMessage());
			} catch (JSONException e1) {
				e1.printStackTrace();
			}
			break;
			
		default:
			JSONtext = "";

		}
		sendMessage(JSONtext);

	}