Java Reference
In-Depth Information
a MachineTreeModel class to adapt the model's information to a JTree object's needs.
(The code for the MachineTreeModel class is in the com.oozinoz.dublin package.)
Displaying the new factory's machines requires building an instance of MachineTreeModel
from the factory composite and wrapping this model in Swing components:
package com.oozinoz.applications;
import javax.swing.*;
import javax.swing.tree.*;
import com.oozinoz.ui.SwingFacade;
import com.oozinoz.dublin.MachineTreeModel;
import com.oozinoz.machine.OozinozFactory;
public class ShowMachineTreeModel
{
public static void main(String[] args)
{
MachineTreeModel mtm =
new MachineTreeModel(OozinozFactory.dublin());
JTree tree = new JTree(mtm);
tree.setFont(SwingFacade.getStandardFont());
SwingFacade.launch(
new JScrollPane(tree), " A New Oozinoz Factory");
}
}
This code produces the tree browser that Figure 29.2 shows.
Search WWH ::




Custom Search