This simple example uses the JazzTreePresenter class to display a hand-built tree. Unfortunately, I can't demonstrate the reflective tree creation features, as this requires a java security permission (accessDeclaredMethod) that webbrowsers deny.
To use this applet, click inside the applet frame and use the following keys to navigate the tree:
up - select the previous sibling
down - select the next sibling
left - go back
right - go forward
z - toggle the zoom mode (zoom selected or zoom siblings)
mouse -- try dragging with the left and right mouse buttons
Source Code
package org.lleta.tests;
import org.lleta.utilities.*;
import org.lleta.utilities.trees.*;
import org.lleta.utilities.trees.reflective.*;
import edu.umd.cs.jazz.*;
import edu.umd.cs.jazz.util.*;
import edu.umd.cs.jazz.event.*;
import edu.umd.cs.jazz.component.*;
import javax.swing.*;
public class TreeTestApplet2 extends JApplet {
public void init() {
// initialize the applet and create a Jazz canvas
setBackground(null);
setVisible(true);
ZCanvas canvas = new ZCanvas();
getContentPane().add(canvas);
// create a dummy tree structure
Node root = new Node("root");
Node childa = new Node("this is child a");
root.addChild(childa);
Node childa1 = new Node("a1");
childa.addChild(childa1);
Node childa2 = new Node("a2");
childa.addChild(childa2);
Node childb = new Node("this is child b");
root.addChild(childb);
Node childc = new Node("this is child c");
root.addChild(childc);
Node childc1 = new Node("c1");
childc.addChild(childc1);
Node childc2 = new Node("c2");
childc.addChild(childc2);
Node childc3 = new Node(new Integer(4));
childc.addChild(childc3);
// create a new jazz tree presenter on the provided canvas
// and make it respond to key events
JazzTreePresenter jtp = new JazzTreePresenter(root, canvas);
this.addKeyListener(jtp.new KeyListener());
this.validate();
}
}