private void txtChatKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtChatKeyReleased
        String msg = txtChat.getText();

        if (evt.getKeyCode() == KeyEvent.VK_TAB) {
            if ("".equals(msg)) return;
            int idx = msg.lastIndexOf(" ");
            if (m_tabCount == 0) {
                m_sub = msg.substring(idx + 1);
                if ("".equals(m_sub)) return;
            }
            List<String> names = m_lobby.autocompleteUser(m_sub);
            Collections.sort(names, new Comparator<String>() {
                public int compare(String o1, String o2) {
                    return o1.compareToIgnoreCase(o2);
                }
            });
            int size = names.size();
            if (size == 0) return;
            int index = m_tabCount;
            while (index >= size) {
                index -= size;
            }
            String newStr = names.get(index);
            if (newStr != null){
                msg = msg.substring(0, idx + 1) + newStr;
                txtChat.setText(msg);
            }
            m_tabCount++;
        } else {
            m_tabCount = 0;
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                try {
                    sendMessage(msg);
                } catch (CommandException e) {
                    String str = "<font class='help'>" + e.getMessage() + "</font>";
                    addMessage(null, str, false);
                }
                txtChat.setText(null);
            }
        }
    }//GEN-LAST:event_txtChatKeyReleased