Package javax.swing.text

Examples of javax.swing.text.Document.insertString()


  }

  public void println(String s) {
    Document d = editor.getDocument();
    try {
      d.insertString(d.getLength(), s + "\n", null);
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
  }
View Full Code Here


                    TextEditor.this.replaceSelection(toReplace);
                    TextEditor.this.select(start, start + toReplace.length());
                }
                else {
                    int pos = TextEditor.this.getCaretPosition();
                    doc.insertString(pos, text, null);
                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }
View Full Code Here

                String replace = (String) REPLACE_FIELD.getSelectedItem();
                replace = replace == null ? "" : replace;
                Document doc = textComponent.getDocument();
                try {
                    doc.remove(pos, find.length());
                    doc.insertString(pos, replace, attributeSet);

                    int last = pos;
                    pos = findNext(false, pos);
                    if (pos > -1) {
                        textComponent.select(pos, pos + find.length());
View Full Code Here

            }
           
            // eliminamos la palabra
            if(ncolumna > posini)
                doc.remove(caret-(ncolumna-posini),ncolumna-posini);
            doc.insertString(caret-(ncolumna-posini),propuesta,elemento.getAttributes());
            editor.setCaretPosition((caret-(ncolumna-posini)) + propuesta.length());
            editor.requestFocus();
        } catch (BadLocationException ex)
        {
            ex.printStackTrace();
View Full Code Here

            replace = replace == null ? "" : replace;
            while (pos > -1) {
                Document doc = textComponent.getDocument();
                try {
                    doc.remove(pos, find.length());
                    doc.insertString(pos, replace, attributeSet);

                    last = pos;
                    pos = findNext(false, pos);
                }
                catch (BadLocationException ble) {
View Full Code Here

                        break;
                    }
                    Document doc = textArea.getDocument();
                    AttributeSet attset = styleContext.getStyle(type);
                    String snippet = new String(buf, 0, len);
                    doc.insertString(doc.getLength(),
                                     snippet, attset);
                    printStream.print(snippet);
                    textArea.setCaretPosition(textArea.getDocument().
                                              getLength());
                } catch (BadLocationException ex) {
View Full Code Here

    /** Output methods **/

    protected void append(String toAppend, AttributeSet style) {
       try {
           Document doc = area.getDocument();
           doc.insertString(doc.getLength(), toAppend, style);

           // Cut the document to fit into the MAX_DOC_SIZE.
           // See JRUBY-4237.
           int extra = doc.getLength() - MAX_DOC_SIZE;
           if (extra > 0) {
View Full Code Here

              links.translate(wordList);
              // Insert words from wordlist
              Document doc = jTextArea1.getDocument();
        for(Iterator i = wordList.iterator();i.hasNext();) {
          Word w = (Word) i.next();
          doc.insertString(doc.getLength(),w.toString(),
                                   w.getAttributes());
        }
      }
      else jTextArea1.setText(message);
      jTextArea1.setEditable(false);
View Full Code Here

        public void mousePressed(MouseEvent arg0)
        {
          Document doc = txtInvoer.getDocument();
          try
          {
                doc.insertString(txtInvoer.getCaretPosition(),smilie,null);
          }
          catch(BadLocationException e2){e2.printStackTrace();}
          subMenu.setVisible(false);
          //OS/2 doesn't get the focus after popup close
          txtInvoer.requestFocus();
View Full Code Here

          {
            Document d = chatSplitPane.getTextInput().getDocument();
            try
            {
              d.remove(wordStart,wordEnd-wordStart);
              d.insertString(wordStart,nick,null);
              //chatSplitPane.getTextInput().setCaretPosition(d.getLength());
              //chatSplitPane.getTextInput().moveCaretPosition(d.getLength());
            } catch (BadLocationException e)
            {
              // TODO Auto-generated catch block
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.