Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. createBranchElement

createBranchElement

Scheduled Pinned Locked Moved Java
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prithaa
    wrote on last edited by
    #1

    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

    T A 2 Replies Last reply
    0
    • P 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

      T Offline
      T Offline
      TorstenH
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • P 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 Offline
        A Offline
        AprNgp
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups