Hi everyone,

I am doing a custom document in which i am always getting an error at the point when i want to use the java HTMLReader class. The compiler says something about an enclosing instance and i really have no idea what the compiler means.

Here is the code

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.print.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.plaf.basic.*;
import javax.swing.text.rtf.*;
import javax.swing.text.html.*;
import javax.swing.undo.*;
import javax.print.attribute.standard.*;
import javax.swing.text.html.HTMLDocument.HTMLReader;

class CustomStyledDocument extends DefaultStyledDocument
{

public CustomStyledDocument(StyleContext styles) 
{
        super(styles);
}

public void test ()
{
      String html = "Test";
      int pop = 0;
      int push = 0;
      HTMLEditorKit.Parser parser = getParser();

//The below three lines is where the error occurs
HTMLDocument.HTMLReader reader = new HTMLDocument.HTMLReader 
                                                        (offset, pop - 1, push, null, false, 
                                                        true, wantsTrailingNewline);

      parser.parse(new StringReader(html), reader, true);
      reader.flush();
}

}

This is exactly what the compiler says

an enclosing instance that contains 
javax.swing.text.html.HTMLDocument.HTMLReader is required

I do not seem to know what the compiler means about my error on using the java HTMLReader class.

I hope someone can help me with this error

Thank You

Yours Sincerely

Richard West

It seems like that's a bug. I've found pages saying it's a bug, but can't find a fix to it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.