/** * Retrieves text from chat window's text-entry field, does preliminary removal of white space, * appends it to the local client's chat window, sends the text to {@link ConnectionToServer} in * order to be sent to the server, clears the local timing / and keypress information associated * with the turn and then clears the text-entry field. */ public void returnPressed() { // System.out.println("return pressed"); // System.err.println("THE CONTENTS ARE:"+jcf.getContentsOfWindow(0)); // System.err.println("---------------------------"); String[] priorChatText = {"", "", ""}; String text = jcf.getTextEnteredInField(); text = text.replaceAll("\\p{Cntrl}", ""); if (jcf instanceof JChatFrameMultipleWindowsWithSendButtonWidthByHeight) { jcf.appendWithCaretCheck( "", cts.getUsername() + ": ", true, text, jcf.getParticipantsOwnWindow(), "SELF"); } cts.sendChatText( (text), startOfTyping, currentTurnBeingConstructedHasBeenBlocked, keyspressedSinceLastTextEntry, priorChatText); currentTurnBeingConstructedHasBeenBlocked = false; jcf.clearTextEntryField(true); clearKeypresses(); }
/** * Retrieves text from chat window's text-entry field, does preliminary removal of white space, * appends it to the local client's chat window, sends the text to {@link ConnectionToServer} in * order to be sent to the server, clears the local timing / and keypress information associated * with the turn and then clears the text-entry field. */ public void sendButtonPressed() { String[] priorChatText = {"", "", ""}; String text = jcf.getTextEnteredInField(); text = text.replaceAll("\n", ""); if (jcf instanceof JChatFrameMultipleWindowsWithSendButtonWidthByHeight) { jcf.appendWithCaretCheck( "", cts.getUsername() + ": ", true, text, jcf.getParticipantsOwnWindow(), "SELF"); } cts.sendChatText( text, startOfTyping, currentTurnBeingConstructedHasBeenBlocked, keyspressedSinceLastTextEntry, priorChatText); currentTurnBeingConstructedHasBeenBlocked = false; jcf.clearTextEntryField(true); clearKeypresses(); }