POLITECHNIKA RZESZOWSK ■ Wydział Elektrotechniki i Informatyki
I import javax.swing.*; import java.awt.*;
ort javax.swing.event.*; import javax.swing.tree.*;
public class JTreeTest extends JFrame implements TrecSelectionr.i stoner ( JTreeTest () {
DefaultMutableTreeNode rootTreeNode ■ new
DefaultMutableTreeNode ("Year") ł DefaultMutableTreeNode nodel ■ new DefaultMutableTreeNode("2008"); rootTreeNode.add(nodel);
DefaultMutableTreeNode nodel1 - new
DefaultMutableTreeNode(“January”); DefaultMutableTreeNode nodel2 - new
DefaultMutableTreeNode("February");
nodel.add(nodel1); nodel.add(nodel2);
DefaultTreeModel treeModel = new DefaultTreeModel(rootTreeNode); JTree tree ■ new JTree (treeModel); tree. adriTroeSelcctionr.i stener (this) ; getContentPane().add(tree);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
84/140
Copyright ig> 2012 Jon PROKOP