/** * 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(); }
/** Closes down the client, freeing resources */ public void closeDown() { try { jcf.setVisible(false); jcf.closeDown(); jcf.dispose(); this.jcf = null; cts = null; System.err.println("ClientEventHandler closing down"); } catch (Exception e) { } System.exit(-111222); System.err.println("CLOSING DOWN THE CLIENT"); }
/** * 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(); }
/** * 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); }
public void changeInterfaceProperties( String uniqueIDGeneratedByServer, int newInterfaceproperties, Object value, Object value2) { if (newInterfaceproperties == (ClientInterfaceEventTracker.changeMazeWindow)) { try { ((ClientMazeGameComms) this.cts.cteh).displayMessageInWindow((String) value, (Long) value2); } catch (Exception e) { e.printStackTrace(); } return; } if (newInterfaceproperties == (ClientInterfaceEventTracker.changeBorderOfMazeFrame)) { ClientMazeGameComms cmgc = (ClientMazeGameComms) this.cts.cteh; cmgc.changeBorderOfMazeFrame((int) value, (Color) value2); } jcf.changeInterfaceProperties(uniqueIDGeneratedByServer, newInterfaceproperties, value, value2); // System.exit(-444445); }
/** * Changes the position of the cursor and the selected text in the WYSIWYG chat window * * @param windowNumber * @param startPos * @param finishPos */ public void wWYSIWYGChangeCursorAndSelectionInWindow( int windowNumber, int startPos, int finishPos) { jcf.wYSIWYGChangeCursorAndSelection(windowNumber, startPos, finishPos); // System.out.println("RECEIVING SELECTION "+startPos+" "+finishPos); }
/** * Removes text from the chat window at the specified position/length * * @param windowNumber * @param offset * @param length */ public void wYSIWYGUpdateDocumentRemove(int windowNumber, int offset, int length) { jcf.wYSIWYGUpdateDocumentRemove(windowNumber, offset, length); }
/** * Adds String to the WYSIWYG chat window at the specified position * * @param windowNumber * @param replacementText * @param offset * @param length */ public void wYSIWYGUpdateDocumentInsert( int windowNumber, String replacementText, int offset, int length) { jcf.wYSIWYGUpdateDocumentInsert(windowNumber, replacementText, offset, length); }