O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 and because I can display those strings in a Java window. In this example, I'll upgrade that code to a new program, browser.java, that will use Java to display XML documents in a window.

Here's how it works. I start by parsing the document 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 saw in the previous chapter. Specifically, I'll create a new class named AppFrame, create an object of that class, and display it:

 public static ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required