Results 1 to 5 of 5

Thread: Extending the Font class

  1. #1
    Join Date
    Dec 2009
    Posts
    263

    Extending the Font class

    Hello,
    I must make a huge mistake, but I do not see it.
    Here is my part of code
    Code:
    import java.awt.Font;
     
    Public class rcfnt extends Font{
        
         Public rcfnt() {
        }
        
    }
    A declaration of "public rcfnt" I have a compilation error can not find symbol: constructor Font (). If I do the same thing with a JPanel (with the import goes well) there is no error. If you can help me with this then it would be great. Thanks in advance.

  2. #2
    Join Date
    Dec 2009
    Posts
    192

    Re: Extending the Font class

    Hello,
    I am new to java, but I think the following code can help you. If you need the code then you can use it
    Have a look at the code
    Code:
    import java.awt.Font;
     
    Public class rcfnt extends Font{
     
        Public rcfnt(String name, int style int size) {
        }
     
    }
    See if this works for you.

  3. #3
    Join Date
    Nov 2009
    Posts
    333

    Re: Extending the Font class

    Hello,
    I think you can start your constructor in the following way
    Code:
    grt(name, style, size);
    Here the compiler can not guess in what order it will use the arguments to the constructor of the superclass. A prior it is not even able to call another constructor implicitly that the empty constructor.

  4. #4
    Join Date
    Dec 2009
    Posts
    263

    Re: Extending the Font class

    Hello,
    At first, I have no compile-time error, I call my new class and use it in return is all good. Thanks you for you help. What explanation given for this? there he literature on this subject. I want to know why the exception was there in my code that is what is the reason for that exception , what was wrong in my code fro which I was getting the error. If you guys know that then please help me so that I can not make the same mistake again. Thanks in advance.

  5. #5
    Join Date
    Nov 2009
    Posts
    347

    Re: Extending the Font class

    Hello,
    This is very simple, you make a constructor on a class that inherits from another. You have in your constructor must call a constructor of the superclass. An implicit empty constructor on the superclass is called. If the superclass has no empty constructor and you do not call one another so you have a compilation error. I hope you are understanding what I can trying you to explain about your code.

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. Replies: 4
    Last Post: 24-08-2011, 09:26 PM
  3. How to use Font class in java?
    By Bottlenecked in forum Software Development
    Replies: 5
    Last Post: 25-02-2010, 09:35 AM
  4. Veranda Poster SG Font: Is new Font?
    By Andrzej in forum Operating Systems
    Replies: 3
    Last Post: 21-11-2009, 08:35 AM
  5. Font & font size changed for menu box!!
    By got2balls in forum Customize Desktop
    Replies: 5
    Last Post: 20-03-2009, 06:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,135,917.83358 seconds with 17 queries