Package javax.swing.text.AbstractDocument

Examples of javax.swing.text.AbstractDocument.BranchElement.replace()


    // Modify the element structure a little and seen how the initial
    // elements are created then.
    LeafElement el1 = doc.new LeafElement(el, null, 0, 3);
    LeafElement el2 = doc.new LeafElement(el, null, 3, 7);
    LeafElement el3 = doc.new LeafElement(el, null, 7, 11);
    el.replace(0, 1, new Element[]{el1, el2, el3});


    TestZoneView zv = new TestZoneView(el, View.Y_AXIS);
    // Set the maximum zone size somewhere inside the second element.
    zv.setMaximumZoneSize(5);
View Full Code Here


    public void testViewToModel04() {
        // Modify the root
        final int oldCount = root.getElementCount();
        BranchElement docRoot = (BranchElement) root;
        final Element[] empty = new Element[0];
        docRoot.replace(0, 1, empty);
        docRoot.replace(docRoot.getElementCount() - 1, 1, empty);
        final int newCount = root.getElementCount();
        assertEquals(oldCount - 2, newCount);
        // Re-load children
        view.removeAll();
View Full Code Here

        // Modify the root
        final int oldCount = root.getElementCount();
        BranchElement docRoot = (BranchElement) root;
        final Element[] empty = new Element[0];
        docRoot.replace(0, 1, empty);
        docRoot.replace(docRoot.getElementCount() - 1, 1, empty);
        final int newCount = root.getElementCount();
        assertEquals(oldCount - 2, newCount);
        // Re-load children
        view.removeAll();
        view.loadChildren(factory);
View Full Code Here

        leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
        ((BranchElement) paragraph).replace(0, 1, leaves);
        BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
        leaves = new Element[1];
        leaves[0] = doc.createLeafElement(branch, null, 16, 21);
        branch.replace(0, 0, leaves);
        // Add this branch to the root
        ((BranchElement) root).replace(1, 0, new Element[] { branch });
        insertOffset = 5 + 2;
    }
View Full Code Here

                doc.new LeafElement(root, null, 1, 1), // [3]
                doc.new LeafElement(root, null, 1, 1), // [4]
                doc.new LeafElement(root, null, 1, 2), // [5]
                doc.new LeafElement(root, null, 2, 3) // [6]
        };
        root.replace(0, 0, leaves);
        assertEquals(0, root.getElementIndex(-1));
        assertEquals(1, root.getElementIndex(0));
        assertEquals(5 /*2*/, root.getElementIndex(1));
        assertEquals(6, root.getElementIndex(2));
        assertEquals(6, root.getElementIndex(3));
View Full Code Here

        AbstractDocument.BranchElement branchElem =
                document.new BranchElement(elem, (AttributeSet) null);
        Element[] arr0 = new Element[] {null, null, null};

        try {
            branchElem.replace(Integer.MIN_VALUE, 5, arr0);
            fail("ArrayIndexOutOfBoundsException is expected");
        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }
View Full Code Here

        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }

        try {
            branchElem.replace(0, -1, arr0);
            fail("ArrayIndexOutOfBoundsException is expected");
        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }
View Full Code Here

        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }

        try {
            branchElem.replace(1, 5, arr0);
            fail("ArrayIndexOutOfBoundsException is expected");
        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }
View Full Code Here

        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }

        try {
            branchElem.replace(0, 2, arr0);
            fail("ArrayIndexOutOfBoundsException is expected");
        } catch (ArrayIndexOutOfBoundsException ex) {
            // valid
        }
    }
View Full Code Here

        leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
        ((BranchElement) paragraph).replace(0, 1, leaves);
        BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
        leaves = new Element[1];
        leaves[0] = doc.createLeafElement(branch, null, 16, 21);
        branch.replace(0, 0, leaves);
        // Add this branch to the root
        ((BranchElement) root).replace(1, 0, new Element[] { branch });
        insertOffset = 5 + 2;
    }
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.