⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 root.java~4~

📁 本软件是使用java 开发的
💻 JAVA~4~
字号:
package datastructure;

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.EventObject;
import javax.swing.*;
import javax.swing.tree.*;

public class Root
    extends JApplet {  //implements TreeSelectionListener {
  private static Root root = null;
  static HelpFrame helpFrame = null;
  static AnimationFrame animationFrame = null;
  public static boolean helpIsOn = false;
  private static String oldTopic = null;
  static AudioClip clip;
  private JTree Tree;
  private DefaultMutableTreeNode DataRoot;
  private DefaultMutableTreeNode LinkListRoot;
  private DefaultMutableTreeNode UnionLinkList;
  private DefaultMutableTreeNode StringRoot;
  private DefaultMutableTreeNode Index;
  private DefaultMutableTreeNode StackRoot;
  private DefaultMutableTreeNode Exp;
  private DefaultMutableTreeNode Hanoi;
  private DefaultMutableTreeNode ArrayRoot;
  private DefaultMutableTreeNode Matrix;
  private DefaultMutableTreeNode TreeRoot;
  private DefaultMutableTreeNode preTree;
  private DefaultMutableTreeNode HufmanTree;
  private DefaultMutableTreeNode GraphicsRoot;
  private DefaultMutableTreeNode Graphics;
  private DefaultMutableTreeNode searchRoot;
  private DefaultMutableTreeNode Binsearch;
  private DefaultMutableTreeNode HashTabel;
  private DefaultMutableTreeNode SortRoot;
  private DefaultMutableTreeNode BubbleSort;
  private DefaultMutableTreeNode HeapSort;
  private DefaultMutableTreeNode ShellSort;
   private DefaultMutableTreeNode maze;
  private DefaultListModel model = new DefaultListModel();
  private String music=null;
  public Root() {
  }

  public void init() {

    Container rootContainer = getContentPane();


    clip = getAudioClip(getCodeBase(), music);



    DataRoot = new DefaultMutableTreeNode("数据结构算法演示");
    LinkListRoot = new DefaultMutableTreeNode("链表");
    UnionLinkList = new DefaultMutableTreeNode("有序链表的合并算法演示");
    StringRoot = new DefaultMutableTreeNode("串");
    Index = new DefaultMutableTreeNode("串的模式匹配算法演示");
    StackRoot = new DefaultMutableTreeNode(" 栈");
    Exp = new DefaultMutableTreeNode("表达式求值算法演示");
    Hanoi = new DefaultMutableTreeNode("Hanoi算法演示");
    ArrayRoot = new DefaultMutableTreeNode(" 数组");
    Matrix = new DefaultMutableTreeNode("稀疏矩阵转置算法演示");
    TreeRoot = new DefaultMutableTreeNode(" 树");
    preTree = new DefaultMutableTreeNode("树的先序遍历算法演示");
    HufmanTree = new DefaultMutableTreeNode("赫夫曼树与赫夫曼编码算法演示");
    GraphicsRoot = new DefaultMutableTreeNode("图");
    Graphics = new DefaultMutableTreeNode("图的深度优先搜索算法演示");
    searchRoot = new DefaultMutableTreeNode("查找");
    Binsearch = new DefaultMutableTreeNode("二分查找算法演示");
    HashTabel = new DefaultMutableTreeNode("哈希表的构造和查找算法演示");
    SortRoot = new DefaultMutableTreeNode(" 排序");
    BubbleSort = new DefaultMutableTreeNode("冒泡排序算法演示");
    HeapSort = new DefaultMutableTreeNode("堆排序算法演示");
    ShellSort=new DefaultMutableTreeNode("希尔排序算法演示");
     maze=new DefaultMutableTreeNode("迷宫算法演示");
    DataRoot.add(this.LinkListRoot);
    DataRoot.add(this.StringRoot);
    DataRoot.add(this.StackRoot);
    DataRoot.add(this.ArrayRoot);
    DataRoot.add(this.TreeRoot);
    DataRoot.add(this.GraphicsRoot);
    DataRoot.add(this.searchRoot);
    DataRoot.add(this.SortRoot);
    LinkListRoot.add(this.UnionLinkList);
    StringRoot.add(this.Index);
    StackRoot.add(this.Exp);
    StackRoot.add(this.Hanoi);
    StackRoot.add(this.maze);
    ArrayRoot.add(this.Matrix);
    TreeRoot.add(this.preTree);
    TreeRoot.add(this.HufmanTree);
    GraphicsRoot.add(this.Graphics);
    searchRoot.add(this.Binsearch);
    searchRoot.add(this.HashTabel);
    SortRoot.add(this.BubbleSort);
    SortRoot.add(this.ShellSort);
    SortRoot.add(this.HeapSort);
    Tree = new JTree(this.DataRoot);
    rootContainer.add(Tree);
    this.showStatus("南昌航空工业学院-软件学院");
    Tree.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent me) {
        doMouseClicked(me);
      }
    });
  }

  public void doMouseClicked(MouseEvent me) {
    TreePath tp = Tree.getPathForLocation(me.getX(), me.getY());

    String path = null;
    if (tp != null)
      path = tp.getLastPathComponent().toString();
    if (path != null) {
      if (path.equals("有序链表的合并算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new unFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("串的模式匹配算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new IndexFrame(this);
        animationFrame.setVisible(true);
      }

      else if (path.equals("表达式求值算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new expFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("Hanoi算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new HanoiFrame(this);

        animationFrame.setVisible(true);
      }
      else if (path.equals("迷宫算法演示")) {
       if (animationFrame != null) {
         animationFrame.dispose();
         animationFrame.kill();
       }
       animationFrame = new MazeFrame(this);
       animationFrame.setVisible(true);
     }

      else if (path.equals("冒泡排序算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new FrameBS(this);
        animationFrame.setVisible(true);
      }
      if (path.equals("希尔排序算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new ShellSortFrame(this);
        animationFrame.setVisible(true);
      }

      else if (path.equals("堆排序算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new hsFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("稀疏矩阵转置算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new MatrixFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("树的先序遍历算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new TreeFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("赫夫曼树与赫夫曼编码算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new HfmFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("图的深度优先搜索算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new GraphFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("二分查找算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new BinsearchFrame(this);
        animationFrame.setVisible(true);
      }
      else if (path.equals("哈希表的构造和查找算法演示")) {
        if (animationFrame != null) {
          animationFrame.dispose();
          animationFrame.kill();
        }
        animationFrame = new HashFrame(this);
        animationFrame.setVisible(true);
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -