解决方案 »

  1.   

    应该不是Java提供的类吧?是自己创建的类吧~
      

  2.   

    好像java中没有SoureTree这个类吧,我记得有TreeMap。这个是自己定义的类吧。
      

  3.   

    好吧,sorry,给你找到了源码。/**
     * Copyright 1999-2004 The Apache Software Foundation.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    /**
     * $Id: SourceTree.java,v 1.1.2.1 2005/08/01 01:30:15 jeffsuttor Exp $
     */
    package com.sun.org.apache.xpath.internal;
    /***
     * This object represents a Source Tree, and any associated
     * information.
     * @xsl.usage internal
     */
    public class SourceTree
    {  /***
       * Constructor SourceTree
       *
       *
       * @param root The root of the source tree, which may or may not be a 
       * {@link org.w3c.dom.Document} node.
       * @param url The URI of the source tree.
       */
      public SourceTree(int root, String url)
      {
        m_root = root;
        m_url = url;
      }  /*** The URI of the source tree.   */
      public String m_url;  /*** The root of the source tree, which may or may not be a 
       * {@link org.w3c.dom.Document} node.  */
      public int m_root;
    }
      

  4.   

    SourceTree 是 Windows 和 OS X 下免费的 Git 和 Hg 客户端。支持创建、克隆、提交、push、pull 和合并等操作。还真有这个类~!
      

  5.   

    --!你看的是不是什么网上的 什么    java编写一个简单的电子相片查看器  的那个啊那里面倒是有这2句
    不过那个SoureTree是他自己写的
      

  6.   

    源码是这个吧 有点长 /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
      /**
      *
      * @author Maoris
      */
      import java.awt.*;
      import java.awt.datatransfer.*;
      import java.awt.event.*;
      import java.awt.image.BufferedImage;
      import java.io.*;
      import java.util.Iterator;
      import java.util.List;
      import javax.swing.*;
      import javax.swing.event.TreeExpansionEvent;
      import javax.swing.event.TreeExpansionListener;
      import javax.swing.filechooser.FileSystemView;
      import javax.swing.tree.*;
      class SoureTree extends JTree {
       BufferedImage ghostImage;
       private TreePath lastPath;
       private Timer hoverTimer;
       FileNode sourceNode;
       public SoureTree() {
       setModel(createTreeModel());
       addTreeExpansionListener(new TreeExpansionListener() {
       public void treeCollapsed(TreeExpansionEvent e) {
       }
       public void treeExpanded(TreeExpansionEvent e) {
       TreePath path = e.getPath();
       if (path != null) {
       FileNode node = (FileNode) path.getLastPathComponent();
       if (!node.isExplored()) {
       DefaultTreeModel model = (DefaultTreeModel) getModel();
       node.explore();
       model.nodeStructureChanged(node);
       }
       }
       }
       });
       this.setCellRenderer(new DefaultTreeCellRenderer() {
       @Override
       public Component getTreeCellRendererComponent(JTree tree,
       Object value, boolean selected, boolean expanded,
       boolean leaf, int row, boolean hasFocus) {
       TreePath tp = tree.getPathForRow(row);
       if (tp != null) {
       FileNode node = (FileNode) tp.getLastPathComponent();
       File f = node.getFile();
       try {
       Icon icon = FileSystemView.getFileSystemView().getSystemIcon(f);
       this.setIcon(icon);
       this.setLeafIcon(icon);
       this.setOpenIcon(icon);
       this.setClosedIcon(icon);
       this.setDisabledIcon(icon);
       } catch (Exception e) {
       e.printStackTrace();
       }
       }
       return super.getTreeCellRendererComponent(tree, value,
       selected, expanded, leaf, row, hasFocus);
       }
       });
       super.setScrollsOnExpand(true);
       hoverTimer = new Timer(1000, new ActionListener() {
       public void actionPerformed(ActionEvent e) {
       if (lastPath == null) {
       return;
       }
       if (getRowForPath(lastPath) == 0) {
       return;
       }
       if (isExpanded(lastPath)) {
       collapsePath(lastPath);
       } else {
       expandPath(lastPath);
       }
       }
       });
       hoverTimer.setRepeats(false);
       this.addKeyListener(new KeyAdapter() {
       @Override
       public void keyPressed(KeyEvent e) {
       int code = e.getKeyCode();
       int modifiers = e.getModifiers();
       if (code == 'v' || code == 'V') {
       System.out.println("find v");
       System.out.println("modifiers:" + modifiers + "\t" + ((modifiers & KeyEvent.CTRL_MASK) != 0));
       }
       if ((modifiers & KeyEvent.CTRL_MASK) != 0 && (code == 'v' || code == 'V')) {
       Transferable tr = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
       TreePath path = getSelectionPath();
       if (path == null) {
       return;
       }
       FileNode node = (FileNode) path.getLastPathComponent();
       if (node.isDirectory()) {
       System.out.println("file cp");
       try {
       List list = (List) (tr.getTransferData(DataFlavor.javaFileListFlavor));
       Iterator iterator = list.iterator();
       File parent = node.getFile();
       while (iterator.hasNext()) {
       File f = (File) iterator.next();
       }
       node.reexplore();
       } catch (Exception ioe) {
       ioe.printStackTrace();
       }
       updateUI();
       }
       }
       }
       });
       }
       public String getFilename() {
       TreePath path = getLeadSelectionPath();
       FileNode node = (FileNode) path.getLastPathComponent();
       return ((File) node.getUserObject()).getAbsolutePath();
       }
       private DefaultTreeModel createTreeModel() {
       File root = FileSystemView.getFileSystemView().getRoots()[0];
       FileNode rootNode = new FileNode(root);
       rootNode.explore();
       return new DefaultTreeModel(rootNode);
       }
       class FileNode extends DefaultMutableTreeNode {
       private boolean explored = false;
       public FileNode(File file) {
       setUserObject(file);
       }
       @Override
       public boolean getAllowsChildren() {
       return isDirectory();
       }
       @Override
       public boolean isLeaf() {
       return !isDirectory();
       }
       public File getFile() {
       return (File) getUserObject();
       }
       public boolean isExplored() {
       return explored;
       }
       public boolean isDirectory() {
       File file = getFile();
       return file.isDirectory();
       }
       @Override
       public String toString() {
       File file = (File) getUserObject();
       String filename = file.toString();
       int index = filename.lastIndexOf(File.separator);
       return (index != -1 && index != filename.length() - 1) ? filename.substring(index + 1) : filename;
       }
       public void explore() {
       if (!isDirectory()) {
       return;
       }
       if (!isExplored()) {
       File file = getFile();
       File[] childrenNode = file.listFiles();
       for (int i = 0; i < childrenNode.length; ++i) {
       if (childrenNode[i].isDirectory()) {
       add(new FileNode(childrenNode[i]));
       }
       }
       explored = true;
       }
       }
       public void reexplore() {
       this.removeAllChildren();
       explored = false;
       explore();
       }
       }
      }