public void insertUpdate(DocumentEvent e) { // this.setCaretPosition(e.getOffset()); this.requestFocusInWindow(); }
public void doRun() { try { //chatFrame.requestFocus(); ChatRoom chatRoom = getActiveChatRoom(); chatRoom.getChatInputEditor().requestFocusInWindow(); updateActiveTab(); } catch (ChatRoomNotFoundException e1) { // Ignore. There may legitamtly not be a chat room. } } };
/** * Requests valid focus to the SendField. */ public void positionCursor() { getChatInputEditor().setCaretPosition(getChatInputEditor().getCaretPosition()); chatAreaButton.getChatInputArea().requestFocusInWindow(); }
private void insertMessage(final BareJid bareJID, final Message message) throws ChatRoomNotFoundException { ChatRoom chatRoom = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID); chatRoom.insertMessage(message); int chatLength = chatRoom.getTranscriptWindow().getDocument().getLength(); chatRoom.getTranscriptWindow().setCaretPosition(chatLength); chatRoom.getChatInputEditor().requestFocusInWindow(); }
/** * Checks to see if enter was pressed and validates room. * * @param e the KeyEvent */ private void checkForEnter(KeyEvent e) { final KeyStroke keyStroke = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()); if (!keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)) && e.getKeyChar() == KeyEvent.VK_ENTER) { e.consume(); sendMessage(); getChatInputEditor().setText(""); getChatInputEditor().setCaretPosition(0); SparkManager.getWorkspace().getTranscriptPlugin().persistChatRoom(this); } else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK))) { final Document document = getChatInputEditor().getDocument(); try { document.insertString(getChatInputEditor().getCaretPosition(), "\n", null); getChatInputEditor().requestFocusInWindow(); chatAreaButton.getButton().setEnabled(true); } catch (BadLocationException badLoc) { Log.error("Error when checking for enter:", badLoc); } } }
/** * Adds a message that is to be sent to the transcript window. * * @param message The message to be displayed. */ private void displaySendMessage( Message message ) { lastActivity = System.currentTimeMillis(); try { getTranscriptWindow().insertMessage( getNickname(), message, ChatManager.TO_COLOR); getChatInputEditor().selectAll(); getTranscriptWindow().validate(); getTranscriptWindow().repaint(); getChatInputEditor().clear(); } catch (Exception ex) { Log.error( "Error sending message", ex); } // Notify users that message has been sent fireMessageSent(message); addToTranscript(message, false); getChatInputEditor().setCaretPosition(0); getChatInputEditor().requestFocusInWindow(); scrollToBottom(); }
getChatInputEditor().requestFocusInWindow(); scrollToBottom();