📄 tree5.java
字号:
package english;
import java.awt.*;
import javax.swing.tree.*;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.BorderLayout;
public class Tree5 extends JPanel {
DefaultMutableTreeNode root;
DefaultMutableTreeNode node1;
DefaultMutableTreeNode node2;
DefaultMutableTreeNode child;
DefaultTreeModel model;
BorderLayout borderLayout1 = new BorderLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JTree jTree1;
public Tree5() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
root = new DefaultMutableTreeNode("节选文章");
node1 = new DefaultMutableTreeNode("简单自测");
node2 = new DefaultMutableTreeNode("高级配音");
model = new DefaultTreeModel(root);
model.insertNodeInto(node1,root,root.getChildCount());
model.insertNodeInto(node2,root,root.getChildCount());
child = new DefaultMutableTreeNode("preside");
model.insertNodeInto(child,node1,node1.getChildCount());
child = new DefaultMutableTreeNode("conference");
model.insertNodeInto(child,node2,node2.getChildCount());
jTree1 = new JTree(model);
JScrollPane jScrollPane1 = new JScrollPane(jTree1,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
this.setLayout(borderLayout1);
this.setPreferredSize(new Dimension(100, 290));
jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.
HORIZONTAL_SCROLLBAR_AS_NEEDED);
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.
VERTICAL_SCROLLBAR_AS_NEEDED);
this.add(jScrollPane1, java.awt.BorderLayout.NORTH);
jScrollPane1.getViewport().add(jTree1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -