Package javax.swing.text

Examples of javax.swing.text.Document


        return index;
    }

    public void completePartialWord(String word) {
        try {
            Document doc = getTextComponent().getDocument();
            doc.remove(insertionStartIndex, insertionEndIndex-insertionStartIndex);
            doc.insertString(insertionStartIndex, word, null);
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    }
View Full Code Here


            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        ParsedURL purl = new ParsedURL(svgDocument.getURL());
                        InputStream is
                            = u.openStream(getInputHandler(purl).
                                           getHandledMimeTypes());
                        // 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

            buf.append(detailLayout.getHeader())
               .append(detailLayout.format(event)).append(
              detailLayout.getFooter());
            if (buf.length() > 0) {
                try {
                  final Document doc = detail.getEditorKit().createDefaultDocument();
                  detail.getEditorKit().read(new StringReader(buf.toString()), doc, 0);
                SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                    detail.setDocument(doc);
                    detail.setCaretPosition(0);
                  }
                });
                } catch (Exception e) {}
            }
          }
        }
 
        if (event == null) {
            try {
              final Document doc = detail.getEditorKit().createDefaultDocument();
              detail.getEditorKit().read(new StringReader("<html>Nothing selected</html>"), doc, 0);
            SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                detail.setDocument(doc);
                detail.setCaretPosition(0);
View Full Code Here

            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        ParsedURL purl = new ParsedURL(svgDocument.getURL());
                        InputStream is
                            = u.openStream(getInputHandler(purl).
                                           getHandledMimeTypes());
                        // 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

    /**
     * @see java.awt.peer.TextAreaPeer#replaceText(java.lang.String, int, int)
     */
    public void replaceText(String text, int start_pos, int end_pos) {
        try {
            final Document doc = ((JTextArea) peerComponent).getDocument();
            doc.remove(start_pos, end_pos - start_pos);
            doc.insertString(start_pos, text, null);
        } catch (BadLocationException ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

        processOutput(text, attribs);
    }


    private void processOutput(String text, AttributeSet attribs) throws BadLocationException {
        Document doc = output.getDocument();
        doc.insertString(0, text, attribs);
        output.setCaretPosition(0);
    }
View Full Code Here

  private class MyDocumentAdapter extends DocumentAdapter {


    @Override
    protected void textChanged(final DocumentEvent e) {
      final Document doc = e.getDocument();
      _dialogBuilder.setOkActionEnabled(validateDirectory(doc));
    }
View Full Code Here

  private class MyDocumentAdapter extends DocumentAdapter {


    @Override
    protected void textChanged(final DocumentEvent e) {
      final Document doc = e.getDocument();
      _dialogBuilder.setOkActionEnabled(validateFile(doc));
    }
View Full Code Here

    //Populating the contents in the blank styled document
    try {
      rtfKit.read(is, styledDoc, 0);

      // Getting the root document
      Document doc = styledDoc.getDefaultRootElement().getDocument();

      //Printing out the contents of the RTF document as plain text
      ret = doc.getText(0, doc.getLength());
    } catch (IOException e) {
      throw new CRException(e);
    } catch (BadLocationException e) {
      throw new CRException(e);
    }
View Full Code Here

            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        InputStream is
                            = 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

TOP

Related Classes of javax.swing.text.Document

Copyright © 2018 www.massapicom. 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.