Creating a Windowed Browser

Converting the code we've written to display a document in a window isn't difficult because that code was purposely written to store the output in an array of strings; I can display those strings in a Java window. In this example, I'll upgrade that code to a new program, browser.java, which will use XML for Java to display XML documents in a window.

Here's how it works; I start by parsing the document that the user wants to parse in the main method:

public static void main(String args[]) {

    displayDocument(args[0]);
    .
    .
    .

Then I'll create a new window using the techniques we've seen in the previous chapter. Specifically, I'll create a new class named AppFrame, create an object of that class, and display it:

 public ...

Get Inside XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.