Error Help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Error Help

Hybrid View

  1. #1
    Join Date
    Oct 2004
    Posts
    151

    Question Error Help

    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

    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

    Code:
    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

  2. #2
    Join Date
    Dec 2003
    Location
    tx/us
    Posts
    131
    I'm not a Java GUI guy but I think it's complaining that both HTMLDocument and HTMLReader are interfaces and you don't have an object (hence the "enclosing instance") that implements them.

    Just a WAG.

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    I'm not sure what you want to manage here...

    ...but I've attatched the source for a very basic HTML 'editor' that
    loads a html file and shows it in text and html mode. It may not be what
    you are looking for though..
    Attached Files Attached Files
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center