Esempio n. 1
0
  public void printSystemMsg(String s) {
    textPane.setEditable(true);
    if (lastEnd >= 0) {
      textPane.setSelectionStart(lastEnd);
      lastEnd = -1;
    } else textPane.setSelectionStart(textPane.getText().length());
    textPane.setSelectionEnd(textPane.getText().length());
    textPane.replaceSelection("");

    textPane.setSelectionStart(textPane.getText().length());
    textPane.setSelectionEnd(textPane.getText().length());
    textPane.setCharacterAttributes(textPane.getStyle("SystemMessage"), true);
    textPane.replaceSelection(s);
    textPane.setEditable(false);
  }
Esempio n. 2
0
  public void printInputMsg(String name) {
    textPane.setEditable(true);
    if (lastEnd >= 0) {
      textPane.setSelectionStart(lastEnd);
      lastEnd = -1;
    } else textPane.setSelectionStart(textPane.getText().length());
    lastEnd = textPane.getSelectionStart();
    textPane.setSelectionEnd(textPane.getText().length());
    textPane.replaceSelection("");

    textPane.setSelectionStart(textPane.getText().length());
    textPane.setSelectionEnd(textPane.getText().length());
    textPane.setCharacterAttributes(textPane.getStyle("SystemMessage"), true);
    textPane.replaceSelection(name + "\u6b63\u5728\u8f38\u5165\u8a0a\u606f..");
    textPane.setEditable(false);
  }
Esempio n. 3
0
  public void printText(String s, String username) {
    textPane.setEditable(true);
    if (lastEnd >= 0) {
      textPane.setSelectionStart(lastEnd);
      lastEnd = -1;
    } else textPane.setSelectionStart(textPane.getText().length());
    textPane.setSelectionEnd(textPane.getText().length());
    textPane.replaceSelection("");

    textPane.setSelectionStart(textPane.getText().length());
    textPane.setSelectionEnd(textPane.getText().length());
    if (username.equals(cwc.fbClient.getUserName()))
      textPane.setCharacterAttributes(textPane.getStyle("UserName"), true);
    else textPane.setCharacterAttributes(textPane.getStyle("FriendName"), true);
    textPane.replaceSelection(username + ":\n");

    textPane.setSelectionStart(textPane.getText().length());
    textPane.setSelectionEnd(textPane.getText().length());
    textPane.setCharacterAttributes(textPane.getStyle("NormalMessage"), true);
    textPane.replaceSelection(" \u2027 " + s + "\n");
    textPane.setEditable(false);
  }
Esempio n. 4
0
  private static void focusParameter() {
    calculateIdx();

    clearHighlight();

    try {
      currFocusHighlight =
          scriptPanel
              .getHighlighter()
              .addHighlight(currFocusHighlightStartIdx, currFocusHighlightEndIdx, CODE_LIGHTER);
    } catch (final BadLocationException e) {
      ExceptionReporter.printStackTrace(e);
    }

    scriptPanel.setSelectionStart(currFocusHighlightStartIdx);
    scriptPanel.setSelectionEnd(currFocusHighlightEndIdx);
    scriptPanel.setCaretPosition(currFocusHighlightEndIdx);
    isFocusFullParameter = true;
  }
Esempio n. 5
0
 private void setEndSelection() {
   content.setSelectionStart(content.getDocument().getLength());
   content.setSelectionEnd(content.getDocument().getLength());
 }
Esempio n. 6
0
 /**
  * Mark the selected text
  *
  * @param textPane The JTextPane under consideration
  */
 public static void setEndSelection(JTextPane textPane) {
   textPane.setSelectionStart(textPane.getDocument().getLength());
   textPane.setSelectionEnd(textPane.getDocument().getLength());
 }