cancel
Showing results for 
Search instead for 
Did you mean: 

Error while creating instance of Document

former_member187658
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

guru_subramanianb
Active Contributor
0 Kudos
Former Member
0 Kudos

I am not sure whether he was speaking about the java.swing.text.Document or the XML version of the document class.

Former Member
0 Kudos

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