The Viewer Xbean

Function

The viewer is a source and a sink Xbean that displays the contents of an XML document in a Swing tree. Here is an example of the simple tree drawn by the viewer Xbean: 

Bean Properties

The viewer Xbean has a single DOMListener property:

DOMListener As with all source Xbeans, the DOMListener property is the next Xbean in the channel. The DOMListener receives the DOM produced by this Xbean.

 closeOnContinue

Indicates whether the window should be closed when the continue button is pressed. 
The viewer also inherits properties from the Java Swing JFrame class. See the Javadoc documentation for JFrame.

Usage

The viewer Xbean is in the org.xbeans.viewer package. The package can be imported into Java source code as follows:

import org.xbeans.viewer.ViewerBean;

Creating a viewer Xbean is accomplished by instantiating the class:

ViewerBean viewer = new ViewerBean();

Note that if you are using a Java Bean design tools found in many Java Integrated Development Environments, the above code is generated automatically when you drag and drop a viewer Xbean into your application.

After creating the viewer Xbean, you need to get a DOM document by registering it with the previous Xbean in the channel.

previousXbean.setDOMListener(viewer);

Finally, you need to decide if the viewer is also to be a source Xbean, that is if the DOM document that is displaying is to be passed on to the next Xbean when the user presses the continue button. To pass the document on to the next Xbean, you simply register the next Xbean to be the DOM Listener.

viewer.setDOMListener(nextXbean);

Again, if you are using a Java Bean design tool, the above calls setting properties may be automatically generated for you.

Source files

source/org/xbeans/viewer/ViewerBean.java
source/org/xbeans/viewer/ViewerBeanBeanInfo.java
source/org/xbeans/viewer/DOMJTree.java
source/org/xbeans/viewer/DOMModel.java