Java Swing AWT Question:
Download Job Interview Questions and Answers PDF
How to Parse HTML used Swing?
Answer:
JEditorPane class is used to display the HTML content that is being written using the classes. When there is a file consisting of the HTML text gives the request to read the file identify the method to read the HTML text using the read() method that is given in HTMLEditorKit. This kit provides lot of tools that delegates the file to a separate parser object. This kid also consists of tools and the abstract inner class consisting of the method as:
public abstract void parse(Reader r, ParserCallback cb) throws IOException
The read() method calls the getParser() method allowing the subclasses to parse the object and use the HTML text. The parser currently uses the package javax.swing.text.html.parser that allow the reading of the file and parse the HTML code. The parameter of the type ParserCallback is used to communicate the progress of the process that is parsing the HTML file.
In the parse() method we listed earlier, you'll notice a very important parameter of type
ParserCallback . This is how the parser communicates its progress.
public abstract void parse(Reader r, ParserCallback cb) throws IOException
The read() method calls the getParser() method allowing the subclasses to parse the object and use the HTML text. The parser currently uses the package javax.swing.text.html.parser that allow the reading of the file and parse the HTML code. The parameter of the type ParserCallback is used to communicate the progress of the process that is parsing the HTML file.
In the parse() method we listed earlier, you'll notice a very important parameter of type
ParserCallback . This is how the parser communicates its progress.
Download Swing AWT Interview Questions And Answers
PDF
Previous Question | Next Question |
Write a program to paint the off-screen buffer in swings? | How does Accessibility works in Swings? |