深入浅出JavaSwing程序设计一书的源代码

源代码在线查看: demotree.java

软件大小: 792 K
上传用户: huanghuanl
关键词: JavaSwing 程序设计 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.swing.*;
				import java.awt.*;
				import java.util.*;
				import javax.swing.tree.*;
				
				public class DemoTree extends JInternalFrame{
				
				  public DemoTree(){
				    super("Demo Tree Structure", true, true, true, true);
				
				    DefaultMutableTreeNode manager;
				    DefaultMutableTreeNode leader;
				    DefaultMutableTreeNode engineer;
				
				    DefaultMutableTreeNode top = new DefaultMutableTreeNode("Empolyee List");
				
				    top.add( manager  = new DefaultMutableTreeNode("Manager") );
				    top.add( leader   = new DefaultMutableTreeNode("Leader") );
				    top.add( engineer = new DefaultMutableTreeNode("Engineer") );
				
				    manager.add( new DefaultMutableTreeNode("C. Fan") );
				    manager.add( new DefaultMutableTreeNode("C. Tomas") );
				    manager.add( new DefaultMutableTreeNode("C. Simth") );
				
				    leader.add( new DefaultMutableTreeNode("K. Jacky") );
				    leader.add( new DefaultMutableTreeNode("M. Shu") );
				
				    engineer.add( new DefaultMutableTreeNode("E. Kevin") );
				    engineer.add( new DefaultMutableTreeNode("H. Alex") );
				    engineer.add( new DefaultMutableTreeNode("G. J.") );
				    engineer.add( new DefaultMutableTreeNode("L. Kate") );
				    engineer.add( new DefaultMutableTreeNode("F. Mike") );
				
				    JTree tree = new JTree(top);
				    JScrollPane treeScroller = new JScrollPane(tree);
				    treeScroller.setBackground(tree.getBackground());
				    setContentPane(treeScroller);
				    setSize( 250, 200);
				    setLocation( 200, 20);	
				  }//end of DemoTree()
				}//end of class DemoTree			

相关资源