📄 demosimplejtree.java
字号:
/*
* DemoSimpleJTree.java
*
* Created on 2007年8月9日, 下午3:34
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.Adam;
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
/**
*
* @author Administrator
*/
public class DemoSimpleJTree extends JFrame{
JTree tree;
DefaultTreeModel treemodel;
DefaultMutableTreeNode root,subroot,subroot2,leaf1,leaf2,leaf3,leaf4;
/** Creates a new instance of DemoSimpleJTree */
public DemoSimpleJTree() {
root=new DefaultMutableTreeNode("根节点");
subroot=new DefaultMutableTreeNode("子节点1");
subroot2=new DefaultMutableTreeNode("子节点2");
leaf1=new DefaultMutableTreeNode("叶子节点1");
leaf2=new DefaultMutableTreeNode("叶子节点2");
leaf3=new DefaultMutableTreeNode("叶子节点3");
leaf4=new DefaultMutableTreeNode("叶子节点4");
treemodel=new DefaultTreeModel(root);
tree=new JTree(treemodel);
treemodel.insertNodeInto(subroot,root,0);
treemodel.insertNodeInto(subroot2,root,1);
subroot.add(leaf1);
subroot.add(leaf2);
subroot2.add(leaf3);
subroot2.add(leaf4);
this.add(tree,BorderLayout.CENTER);
this.setTitle("JTree简单应用");
this.setBounds(100,100,250,200);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new DemoSimpleJTree();
}
/*
private void add(JTree tree, String CENTER) {
throw new UnsupportedOperationException("Not yet implemented");
}
private void setTitle(String string) {
throw new UnsupportedOperationException("Not yet implemented");
}
private void setBounds(int i, int i0, int i1, int i2) {
throw new UnsupportedOperationException("Not yet implemented");
}
private void setVisible(boolean b) {
throw new UnsupportedOperationException("Not yet implemented");
}
private void setDefaultCloseOperation(int EXIT_ON_CLOSE) {
throw new UnsupportedOperationException("Not yet implemented");
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -