Package javax.swing.text

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


                        InputStream is = ParsedURL.checkGZIP(u.openStream());

                        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


                    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

            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

            }
        }
        Transferable content = getToolkit().getSystemClipboard().getContents(this);
        if (content.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            try {
                d.insertString(start, (String) content.getTransferData(DataFlavor.stringFlavor), new SimpleAttributeSet());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
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

    public void testJTextFieldDocumentStringInt() {
        String str1 = "AAA";
        String str2 = "testJTextFieldDocumentStringInt()";
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        JTextField tf = new JTextField(doc, str2, 8);
        assertEquals(str2, tf.getText());
View Full Code Here

        assertEquals(str2, tf.getText());
        assertEquals(doc, tf.getDocument());
        assertEquals(8, tf.getColumns());
        doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        tf = new JTextField(doc, null, 6);
        assertEquals(str2, tf.getText());
View Full Code Here

       
        Document doc = textPane.getDocument();
        int oldPosition = textPane.getCaretPosition();
     
        try {
          doc.insertString(doc.getLength(), message, textPane.getStyle(style));
        } catch (BadLocationException e) {
          e.printStackTrace();
        }
       
        textPane.setDocument(doc);
View Full Code Here

            if (jscrollpane.getViewport().getView() == jtextarea) {
                flag = (double) jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double) (a.getSize() * 4) > (double) jscrollbar.getMaximum();
            }

            try {
                document.insertString(document.getLength(), s, (AttributeSet) null);
            } catch (BadLocationException badlocationexception) {
                ;
            }

            if (flag) {
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.