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

📄 myclienttree.java

📁 Java实现的图书管理系统
💻 JAVA
字号:
/* * MyClientTree.java * * Created on 2003年5月8日, 下午4:51 *//** * * @author  administrator */import java.awt.*;import javax.swing.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.tree.*;// Takes an array of Strings and makes the first// element a node and the rest leaves:class Branch {  DefaultMutableTreeNode r;  public Branch(String[] data) {    r = new DefaultMutableTreeNode(data[0]);    for(int i = 1; i < data.length; i++)      r.add(new DefaultMutableTreeNode(data[i]));  }  public DefaultMutableTreeNode node() {     return r;   }} class MyClientTree extends JTree {        /** Creates a new instance of MyClientTree */    String[][] data = {    /*{ "Colors", "Red", "Blue", "Green" },    { "Flavors", "Tart", "Sweet", "Bland" },    { "Length", "Short", "Medium", "Long" },    { "Volume", "High", "Medium", "Low" },    { "Temperature", "High", "Medium", "Low" },    { "Intensity", "High", "Medium", "Low" },     */        {"查询"},        {"借阅"},        {"归还"}  };      DefaultTreeModel model;    DefaultMutableTreeNode root, child;        public MyClientTree()     {        // Capture the tree's model:        model =(DefaultTreeModel)this.getModel();        //fill the data        root = new DefaultMutableTreeNode("图书管理系统");       //add the root node        model.setRoot(root);                //add the leaf nodes        int i=0;        while(i < data.length)         {          child = new Branch(data[i++]).node();                  model.insertNodeInto(child, root, model.getChildCount(root));          // This puts the new node on the           // currently chosen node.        }//        setSize(100, 250);    }    } 

⌨️ 快捷键说明

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