Exemple #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);
  }
Exemple #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);
  }
Exemple #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);
  }
  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;
  }
Exemple #5
0
 private void setEndSelection() {
   content.setSelectionStart(content.getDocument().getLength());
   content.setSelectionEnd(content.getDocument().getLength());
 }
Exemple #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());
 }