createBranchElement
-
Hello,
public class Doc extends PlainDocument {
private static final long serialVersionUID = 1L; /\*protected AbstractElement createDefaultRoot() { return super.createDefaultRoot(); } \*/ protected Element createBranchElement(Element parent,AttributeSet a) { return super.createBranchElement(parent, a); }
}
public class TestDocView {
Doc D = new Doc();
AbstractDocument.BranchElement E1 = (BranchElement) D.getDefaultRootElement();
D.createBranchElement(E1, A);
}I get runtime error for
D.createBranchElement(E1, A);
saying Illegal casting of AbstractDocument.BranchElement. How should I use CreateBranchElement()? Thanks Prithaa
-
Hello,
public class Doc extends PlainDocument {
private static final long serialVersionUID = 1L; /\*protected AbstractElement createDefaultRoot() { return super.createDefaultRoot(); } \*/ protected Element createBranchElement(Element parent,AttributeSet a) { return super.createBranchElement(parent, a); }
}
public class TestDocView {
Doc D = new Doc();
AbstractDocument.BranchElement E1 = (BranchElement) D.getDefaultRootElement();
D.createBranchElement(E1, A);
}I get runtime error for
D.createBranchElement(E1, A);
saying Illegal casting of AbstractDocument.BranchElement. How should I use CreateBranchElement()? Thanks Prithaa
a runtime Error?? Please use an IDE. Eclipse and Netbeans are free. No need to work on console. Your Exception pops because the method
createBranchElement(Element parent, AttributeSet a)
is inheriated from [AbstractDocument](http://docs.oracle.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html#createBranchElement\(javax.swing.text.Element, javax.swing.text.AttributeSet))[[^](http://docs.oracle.com/javase/6/docs/api/javax/swing/text/AbstractDocument.html#createBranchElement\(javax.swing.text.Element, javax.swing.text.AttributeSet))]. I guess it doesn't return much.regards Torsten When I'm not working
-
Hello,
public class Doc extends PlainDocument {
private static final long serialVersionUID = 1L; /\*protected AbstractElement createDefaultRoot() { return super.createDefaultRoot(); } \*/ protected Element createBranchElement(Element parent,AttributeSet a) { return super.createBranchElement(parent, a); }
}
public class TestDocView {
Doc D = new Doc();
AbstractDocument.BranchElement E1 = (BranchElement) D.getDefaultRootElement();
D.createBranchElement(E1, A);
}I get runtime error for
D.createBranchElement(E1, A);
saying Illegal casting of AbstractDocument.BranchElement. How should I use CreateBranchElement()? Thanks Prithaa
prithaa wrote:
AbstractDocument.BranchElement E1 = (BranchElement) D.getDefaultRootElement();
You haven't shown us the implementation of
getDefaultRootElement()
Also, what's the relation between BranchElement and Element.
Apurv If Java had true garbage collection, most programs would delete themselves upon execution.