Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:急求:在java中没有有显示系统文件目录树的控件 [Re:hikelee]
vssivl

克斯



发贴: 20
积分: 0
于 2004-11-05 18:03 user profilesend a private message to usersend email to vssivlsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
package gui;

import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class FileTreeTest {
  public static void main(String[] args) {
    try {
      if (args.length != 1) {
        System.out.println("Please supply one initial directory");
        System.exit(0);
      }
      JFrame f = new JFrame("File Tree Test");
      final FileTree ft = new FileTree(args[0]);

      ft.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
          TreePath path = evt.getPath();
          String name = ft.getPathName(path);
          File file = ft.getFile(path);
          System.out.println("File " + name + " has been "
            + (evt.isAddedPath() ? "selected" : "deselected"));
          System.out.println("File object is " + file);
        }
      });

      f.getContentPane().add(new JScrollPane(ft));
      f.setSize(300, 300);
      f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
          System.exit(0);
        }
      });
      f.setVisible(true);
    } catch (FileNotFoundException e) {
      System.out.println("File " + args[0] + " not found");
    }
  }
}


vssivl edited on 2004-11-05 18:06


话题树型展开
人气 标题 作者 字数 发贴时间
9094 急求:在java中没有有显示系统文件目录树的控件 hikelee 26 2004-10-25 16:48
7587 Re:急求:在java中没有有显示系统文件目录树的控件 kavinwang 19 2004-10-25 21:22
7567 Re:急求:在java中没有有显示系统文件目录树的控件 hikelee 31 2004-11-05 10:56
7623 Re:急求:在java中没有有显示系统文件目录树的控件 vssivl 4911 2004-11-05 18:02
7755 Re:急求:在java中没有有显示系统文件目录树的控件 vssivl 2355 2004-11-05 18:03
7619 Re:急求:在java中没有有显示系统文件目录树的控件 vssivl 27 2004-11-05 18:07
7584 Re:急求:在java中没有有显示系统文件目录树的控件 hikelee 55 2004-11-05 23:15
7772 Re:急求:在java中没有有显示系统文件目录树的控件 hikelee 5556 2004-11-06 00:02
7397 Re:急求:在java中没有有显示系统文件目录树的控件 littledeer1974 8 2004-11-06 09:22
7368 Re:急求:在java中没有有显示系统文件目录树的控件 floater 52 2004-11-07 03:08
7818 Re:急求:在java中没有有显示系统文件目录树的控件 vssivl 13 2004-11-08 10:57

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923