Package javax.swing.text

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


  public void addTextToSend(String text)
  {
    Document d = chatSplitPane.getTextInput().getDocument();
    try
    {
      d.insertString(d.getLength(),text,null);
    } catch (BadLocationException e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here


                .uniqueName("effigy"));
        Document doc = new DefaultStyledDocument();
        effigy.setDocument(doc);

        if (text != null) {
            doc.insertString(0, text, null);
        }

        return effigy;
    }
View Full Code Here

                String line = reader.readLine();

                while (line != null) {
                    // Translate newlines to Java form.
                    doc.insertString(doc.getLength(), line + "\n", null);
                    line = reader.readLine();
                }
            } finally {
                if (reader != null) {
                    reader.close();
View Full Code Here

     */
    public void typeText(String text) {
        Document doc = getDocument();
        for (int i = 0; i < text.length(); i++) {
            try {
                doc.insertString(getCaretPosition(), new String(text.substring(i, i + 1)), null);
                setCaretPosition(getCaretPosition() + 1);
            }
            catch (BadLocationException e) {
                throw new UnsupportedOperationException(e.getMessage());
            }
View Full Code Here

                String t = doc.getText(i, len);
                int j = 0; String s = "";
                //for (int j=0; j<len && t.charAt(j)==' '; j++);
                while (j<len && t.charAt(j++)==' ') s += " ";
                if (s.length() > 0)
                    doc.insertString(p, s, null);
                //setMessage(p+" "+k+" "+len);
            } catch (BadLocationException x) {
                setMessage(x);
            }
        }
View Full Code Here

                            = u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

                        // u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

                        // u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

      try {
        if (doc instanceof AbstractDocument) {
          ((AbstractDocument) doc).replace(start, end - start, str, null);
        } else {
          doc.remove(start, end - start);
          doc.insertString(start, str, null);
        }
      } catch (BadLocationException e) {
        throw new IllegalArgumentException(e.getMessage());
      }
    }
View Full Code Here

  public void insertText(String text, int position) {
    UISpecAssert.assertTrue(isEditable());
    Document document = jTextComponent.getDocument();
    try {
      document.insertString(position, text, document.getDefaultRootElement().getAttributes());
    }
    catch (BadLocationException e) {
      AssertAdapter.fail("Position should be between 0 and " + document.getLength());
    }
  }
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.