/** * 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(); }
/** * Appends text to the participant's chat window. Text usually contains * * @param s * @param windowNumber */ public void appendWithCaretCheck( String msgFROMSERVERID, String prefix, boolean showPrefix, String text, int windowNumber, Object style) { String s = ""; String t = ""; // if(prefix==null)System.exit(-5); if (prefix != null) s = s + prefix; if (text != null) t = t + text; jcf.appendWithCaretCheck(msgFROMSERVERID, s + ": ", showPrefix, t, windowNumber, style); }
/** * 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(); }