var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-20738293-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script')"/>
jutleo
欢迎走进有风的地方~~
posts - 63,  comments - 279,  trackbacks - 0
package GUI;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeSelectionModel;

public class TreeTest extends JFrame {

    
public TreeTest() {
        DefaultMutableTreeNode Program 
= new DefaultMutableTreeNode("Program");
        DefaultMutableTreeNode Office 
= new DefaultMutableTreeNode("Office");
        DefaultMutableTreeNode Word 
= new DefaultMutableTreeNode("Word");
        DefaultMutableTreeNode PowerPoint 
= new DefaultMutableTreeNode("PowerPoint");
        DefaultMutableTreeNode Access 
= new DefaultMutableTreeNode("Access");
        DefaultMutableTreeNode Excel 
= new DefaultMutableTreeNode("Excel");
        DefaultMutableTreeNode Java 
= new DefaultMutableTreeNode("Java");
        DefaultMutableTreeNode j2se 
= new DefaultMutableTreeNode("j2se");
        DefaultMutableTreeNode j2ee 
= new DefaultMutableTreeNode("j2ee");
        DefaultMutableTreeNode j2me 
= new DefaultMutableTreeNode("j2me");
        DefaultMutableTreeNode Application 
= new DefaultMutableTreeNode("Application");
        DefaultMutableTreeNode Dreamweaver 
= new DefaultMutableTreeNode("Dreamweaver");
        DefaultMutableTreeNode PotoShop 
= new DefaultMutableTreeNode("PotoShop");
        DefaultMutableTreeNode VisualStudio 
= new DefaultMutableTreeNode("VisualStudio");
        
        Office.add(Word);
        Office.add(PowerPoint);
        Office.add(Access);
        Office.add(Excel);
        Java.add(j2se);
        Java.add(j2ee);
        Java.add(j2me);
        Application.add(Dreamweaver);
        Application.add(PotoShop);
        Application.add(VisualStudio);
        Program.add(Office);
        Program.add(Java);
        Program.add(Application);
        
        JTree jtree 
= new JTree(Program);
        jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
        jtree.setRowHeight(
20);

        jtree.addTreeSelectionListener(
new TreeSelectionListener() {
            
public void valueChanged(TreeSelectionEvent e) {
                JTree tree 
= (JTree)e.getSource();
                System.out.println(e.getPath());
            }

        }
);

        
        JScrollPane jscrollpane 
= new JScrollPane(jtree);
        
        
this.add(jscrollpane);
    }

    
    
public static void main(String[] args) {
        TreeTest tt 
= new TreeTest();
        tt.setBounds(
100200300400);
        tt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        tt.setVisible(
true);
        
    }

    
}

posted on 2007-12-17 22:06 凌晨风 阅读(489) 评论(0)  编辑  收藏 所属分类: Java学习笔记

只有注册用户登录后才能发表评论。


网站导航:
 

<2007年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(11)

我参与的团队

随笔分类

随笔档案

文章分类

文章档案

新闻分类

新闻档案

收藏夹

围脖

最新随笔

搜索

  •  

最新评论

阅读排行榜

评论排行榜