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. Doc extends PlainDocument problem

Doc extends PlainDocument problem

Scheduled Pinned Locked Moved Java
helpquestion
8 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 I am using the following code to use createLeafElement from PlainDocument public class Doc extends PlainDocument { private static final long serialVersionUID = 1L; protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) { return createLeafElement(parent, a, p0, p1); } } The above class without the createLeafElement() method works fine .But if I add this method I get runtime error saying program not responding. My purpose is to use createLeafElement() method.How can I use it? Thanks Prithaa

    N 1 Reply Last reply
    0
    • P prithaa

      Hello I am using the following code to use createLeafElement from PlainDocument public class Doc extends PlainDocument { private static final long serialVersionUID = 1L; protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) { return createLeafElement(parent, a, p0, p1); } } The above class without the createLeafElement() method works fine .But if I add this method I get runtime error saying program not responding. My purpose is to use createLeafElement() method.How can I use it? Thanks Prithaa

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      0. Wrap code in <pre> tags please. 1. What is the exact exception? Try using copy/paste. 2. The method wont work try calling the super implementation:

      public class Doc extends PlainDocument {

      private static final long serialVersionUID = 1L;	
      
      protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) {
          return super.createLeafElement(parent, a, p0, p1);
      }	
      

      }

      3. Finally, why override if you are not changing anything?


      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

      P U 2 Replies Last reply
      0
      • N Nagy Vilmos

        0. Wrap code in <pre> tags please. 1. What is the exact exception? Try using copy/paste. 2. The method wont work try calling the super implementation:

        public class Doc extends PlainDocument {

        private static final long serialVersionUID = 1L;	
        
        protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) {
            return super.createLeafElement(parent, a, p0, p1);
        }	
        

        }

        3. Finally, why override if you are not changing anything?


        Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

        P Offline
        P Offline
        prithaa
        wrote on last edited by
        #3

        thanks for your advice I dont want to override but the method createLeafElemenmt() and createdefaultroot() are not visible when I want to use them directly. With the following object D1 the methods are not visible. PlainDocument D1 = new PlainDocument(); Thanks for your time

        N 1 Reply Last reply
        0
        • P prithaa

          thanks for your advice I dont want to override but the method createLeafElemenmt() and createdefaultroot() are not visible when I want to use them directly. With the following object D1 the methods are not visible. PlainDocument D1 = new PlainDocument(); Thanks for your time

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #4

          The example I gave should work as it calls the protected method on the super class.


          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

          P 1 Reply Last reply
          0
          • N Nagy Vilmos

            The example I gave should work as it calls the protected method on the super class.


            Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

            P Offline
            P Offline
            prithaa
            wrote on last edited by
            #5

            yes it does do the needful but why are the methods not visible in the subclasses protected methods should be visible in subclasses,is it not? thanks prithaa

            N 1 Reply Last reply
            0
            • P prithaa

              yes it does do the needful but why are the methods not visible in the subclasses protected methods should be visible in subclasses,is it not? thanks prithaa

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #6

              Read this[^] to understand access modifiers. If something is protected it is visible within the package and to any sub-classes. By being visible to the sub-classes, it can be called from the class, but not from classes referencing the class.


              Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

              P 1 Reply Last reply
              0
              • N Nagy Vilmos

                Read this[^] to understand access modifiers. If something is protected it is visible within the package and to any sub-classes. By being visible to the sub-classes, it can be called from the class, but not from classes referencing the class.


                Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                P Offline
                P Offline
                prithaa
                wrote on last edited by
                #7

                thanks

                1 Reply Last reply
                0
                • N Nagy Vilmos

                  0. Wrap code in <pre> tags please. 1. What is the exact exception? Try using copy/paste. 2. The method wont work try calling the super implementation:

                  public class Doc extends PlainDocument {

                  private static final long serialVersionUID = 1L;	
                  
                  protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) {
                      return super.createLeafElement(parent, a, p0, p1);
                  }	
                  

                  }

                  3. Finally, why override if you are not changing anything?


                  Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                  U Offline
                  U Offline
                  User 11808067
                  wrote on last edited by
                  #8

                  My problem is that,when i enter a numeric value starting with 0 for ex: 0123 then at the time of saving,
                  it automatically converts this numeric value into something else like 83 or 9 etc.

                  hadoop training in chennai | Oracle DBA Training in Chennai | Informatica Training in Chennai

                  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