Skip to Content
avatar image
Former Member

Error while creating instance of Document

Hi

I am creating a java file , in which i m creating an instance of type Document. But it is givign the error "The type Document cannot be instantiated".

anybody can please help?

Regadrs,

Anupreet

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jul 27, 2005 at 11:10 AM

    Hi Anupreet,

    If you are trying to use <b>Document doc = new Document()</b> then it is not possible cos Document is an interface. Instead use classes AbstractDocument or DefaultStyledDocument in package javax.swing.text or implement Document interface in your class.

    use code like this

    Document doc.
    doc = new AbstractDocument();
    or 
    doc = new DefaultStyledDocument();
    ----
    

    Hope it helps you.

    Regards,

    Narinder Singh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 27, 2005 at 11:22 AM
    Add comment
    10|10000 characters needed characters exceeded