top.add(jiaotong);
top.add(zhusu);
top.add(binguan);
top.add(luying);
top.add(jiesu);
}
/**
* This method initializes jEditorPane
*
* @return javax.swing.JEditorPane
*/
private JEditorPane getJEditorPane() {
if (jEditorPane == null) {
jEditorPane = new JEditorPane();
}
return jEditorPane;
}
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree
.getLastSelectedPathComponent();
if (node == null)
// Nothing is selected.
return;
if(node.isRoot()){
jEditorPane.setText("黄山的简介");
}
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e){
e.printStackTrace();
}
new TreeDemo1().setVisible(true);
}
});
}
}
java,jsp带checkbox的树形菜单,如何实现?jsp中带有checkbox的属性菜单需要用easyui组件来实现java树形菜单系统代码,代码如下java树形菜单系统代码:
!DOCTYPE html
html
head
meta charset="UTF-8"
titleCheckBox Tree - jQuery EasyUI Demo/title
link rel="stylesheet" type="text/css" href="https://www.04ip.com/themes/default/easyui.css"
link rel="stylesheet" type="text/css" href="https://www.04ip.com/themes/icon.css"
link rel="stylesheet" type="text/css" href="https://www.04ip.com/demo.css"
script type="text/javascript" src="https://www.04ip.com/jquery.min.js"/script
script type="text/javascript" src="https://www.04ip.com/jquery.easyui.min.js"/script
/head
body
h2CheckBox Tree/h2
pTree nodes with check boxes./p
div style="margin:20px 0;"
a href="https://www.04ip.com/post/#" class="easyui-linkbutton" onclick="getChecked()"GetChecked/a
/div
div style="margin:10px 0"
input type="checkbox" checked onchange="$('#tt').tree({cascadeCheck:$(this).is(':checked')})"CascadeCheck
input type="checkbox" onchange="$('#tt').tree({onlyLeafCheck:$(this).is(':checked')})"OnlyLeafCheck
/div
div class="easyui-panel" style="padding:5px"
ul id="tt" class="easyui-tree" data-options="url:'tree_data1.json',method:'get',animate:true,checkbox:true"/ul
/div
script type="text/javascript"
function getChecked(){
var nodes = $('#tt').tree('getChecked');
var s = '';
for(var i=0; inodes.length; i++){
if (s != '') s += ',';
s += nodes[i].text;
}
alert(s);
}
/script
/body
/html
运行效果:
如何用Java实现树形结构?。?/h2>package tree;
import java.util.LinkedList;
import java.util.List;
/**
* 功能:把一个数组的值存入二叉树中,然后进行3种方式的遍历
*
* 参考资料0:数据结构(C语言版)严蔚敏
*
* 参考资料1:
*
* 参考资料2:
*
* @author ocaicai@yeah.net @date: 2011-5-17
*
*/
public class BinTreeTraverse2 {
private int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
private static ListNode nodeList = null;
/**
* 内部类:节点
*
* @author ocaicai@yeah.net @date: 2011-5-17
*
*/
private static class Node {
Node leftChild;
Node rightChild;
int data;
Node(int newData) {
leftChild = null;
rightChild = null;
data = https://www.04ip.com/post/newData;
}
}
public void createBinTree() {
nodeList = new LinkedListNode();
// 将一个数组的值依次转换为Node节点
for (int nodeIndex = 0; nodeIndexarray.length; nodeIndex++) {
- java查询数组中是否包含某一个值 javamongodb数组查询
- redis实战电子书 redisjava书籍
- javaredis集群 javaredis列队
- Redis队列排队 redis队列java
- java mongodb aggregate mongodb的教程java
- redis实现秒杀功能java redis和mq实现秒杀
- redis队列实现秒杀java redis推时队列
- java redis面试 javaredis试题
- spring监听redis队列 java中redis监听
- mysql查询树形结构数据 mysql查询树层级
