急!!!谁有JAVA APPLET写的树型目录的源代码?(100分)

  • 主题发起人 主题发起人 若影
  • 开始时间 开始时间

若影

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能告诉我,是否有JAVA APPLET写的树型目录的源代码?
 
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%--//&amp;Eacute;è&amp;Ouml;&amp;Atilde;session&amp;pound;&amp;not;&amp;Igrave;á&amp;sup1;&amp;copy;&amp;Oacute;&amp;Atilde;&amp;raquo;§&amp;micro;&amp;Ccedil;&amp;Acirc;&amp;frac12;&amp;frac12;&amp;Oacute;&amp;iquest;&amp;Uacute;
//session.setAttribute("userName","dxd");
//topMenu=(String)session.getAttribute("userName");
--%>
<%
String topMenu;
String sDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";
try
{
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
%>
<%!
public ResultSet executeQuery(String sql)
{
String sConnStr="jdbc:odbc:tree";
String user="dir";
String password="dir";
Connection conn=null;
ResultSet rs=null;
rs=null;
try
{
conn=DriverManager.getConnection(sConnStr,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println(ex.getMessage());
}
return rs;
}
%>
<html>
<head>
<title>&amp;Ecirc;÷×&amp;acute;&amp;sup2;&amp;Euml;&amp;micro;&amp;yen;
</title>
<style><!--
A:link {text-decoration:none}
A:visited {text-decoration:none}
A:hover {color:#99CCFF;text-decoration:none}
-->
</style>
<script LANGUAGE="JavaScript">
<!--
//&amp;Atilde;&amp;iquest;&amp;cedil;&amp;ouml;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;Oacute;&amp;ETH;&amp;Ograve;&amp;raquo;&amp;cedil;&amp;ouml;&amp;Ecirc;&amp;yacute;×é,°ü&amp;ordm;&amp;not;
4+n&amp;cedil;&amp;ouml;&amp;Ocirc;&amp;ordf;&amp;Euml;&amp;Oslash;
// node[0]&amp;Icirc;&amp;ordf;0/1 &amp;para;&amp;Ocirc;&amp;Oacute;&amp;brvbar;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;micro;&amp;Auml;&amp;Otilde;&amp;sup1;&amp;iquest;&amp;ordf;/&amp;sup1;&amp;Oslash;±&amp;Otilde;
// node[1]&amp;Icirc;&amp;ordf;0/1 &amp;para;&amp;Ocirc;&amp;Oacute;&amp;brvbar;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;frac14;&amp;ETH;&amp;micro;&amp;Auml;&amp;sup1;&amp;Oslash;±&amp;Otilde;/&amp;Otilde;&amp;sup1;&amp;iquest;&amp;ordf;
// node[2]&amp;Icirc;&amp;ordf;1 &amp;Egrave;&amp;ccedil;&amp;sup1;&amp;ucirc;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;micro;&amp;Auml;×&amp;Oacute;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;Ecirc;&amp;Ccedil;&amp;Icirc;&amp;Auml;&amp;micro;&amp;micro;
// node[3]&amp;Ecirc;&amp;Ccedil;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;micro;&amp;Auml;&amp;Atilde;&amp;ucirc;&amp;sup3;&amp;AElig;
// node[4]...node[4+n]&amp;Icirc;&amp;ordf;n&amp;cedil;&amp;ouml;×&amp;Oacute;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;
// &amp;sup3;&amp;otilde;&amp;Ecirc;&amp;frac14;&amp;raquo;&amp;macr;&amp;sup2;&amp;Euml;&amp;micro;&amp;yen;&amp;micro;&amp;Auml;&amp;Ecirc;&amp;yacute;&amp;frac34;&amp;Yacute;
function generateTree()
{
var aux1, aux2, aux3, aux4
foldersTree = folderNode("&amp;Icirc;&amp;Ograve;&amp;micro;&amp;Auml;&amp;Iacute;&amp;oslash;&amp;Otilde;&amp;frac34;")
<%
//menu_id,menu_name,parent_menu_id,folder_or_file,menu_location
String sql="select * from tree_menu ";
ResultSet RS;
RS=executeQuery(sql);
System.out.println(sql);
try
{
while(RS.next())
{
String foldersTree;
int id=RS.getInt("menu_id");
System.out.println(id);
int loc=RS.getInt("menu_location");
int folder_or_file=RS.getInt("folder_or_file");
if(loc==1){
foldersTree="foldersTree";
}else
{
foldersTree="aux"+(int)(loc-1);
}
//&amp;Aacute;&amp;not;&amp;frac12;&amp;Oacute;
if(folder_or_file==1){
out.println("aux"+loc+" = appendChild("+foldersTree+", folderNode('<a href=main.jsp?menuid="+id+"&amp;loc="+loc+" target=folderFrame>"+RS.getString("menu_name")+"</a>'));");
}else
{
out.println("appendChild("+foldersTree+", generateDocEntry(0, '"+RS.getString("menu_name")+"', 'sample1.htm', ''));");
}
}
}
catch(Exception e)
{
out.println(e.toString());
}
%>
}
// &amp;acute;&amp;acute;&amp;frac12;¨&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;micro;&amp;Auml;&amp;cedil;¨&amp;Ouml;ú&amp;ordm;&amp;macr;&amp;Ecirc;&amp;yacute;
function folderNode(name)
{
var arrayAux
arrayAux = new Array
arrayAux[0] = 0
arrayAux[1] = 0
arrayAux[2] = 0
arrayAux[3] = name
return arrayAux
}
function leafNode(name)
{
var arrayAux
arrayAux = new Array
arrayAux[0] = 0
arrayAux[1] = 0
arrayAux[2] = 1
arrayAux[3] = name
return arrayAux
}
function appendChild(parent, child)
{
parent[parent.length] = child
return child
}
function generateDocEntry(icon,do
cDescription, link)
{
var retString =""
if (icon==0)
retString = "<A href='"+link+"' target=folderFrame><img src='doc.gif' alt='&amp;Ocirc;&amp;Uacute;&amp;Oacute;&amp;Ograve;±&amp;szlig;&amp;iquest;ò&amp;frac14;&amp;Uuml;&amp;Ouml;&amp;ETH;&amp;acute;ò&amp;iquest;&amp;ordf;'"
else
retString = "<A href='"+link+"' target=_blank><img src='link.gif' alt='&amp;Ocirc;&amp;Uacute;&amp;ETH;&amp;Acirc;&amp;acute;°&amp;iquest;&amp;Uacute;&amp;Ouml;&amp;ETH;&amp;acute;ò&amp;iquest;&amp;ordf;'"
retString = retString + " border=0></a><td nowrap><font style='font-size:9pt;font-family:&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;'>" +do
cDescription + "</font>"
return retString
}
//&amp;Euml;&amp;cent;&amp;ETH;&amp;Acirc;&amp;Ecirc;÷×&amp;acute;&amp;sup2;&amp;Euml;&amp;micro;&amp;yen;
function redrawTree()
{
vardo
c = top.treeFrame.window.document
doc.clear()
doc.write("<body bgcolor='white'>")
redrawNode(foldersTree,do
c, 0, 1, "")
doc.close()
}
function redrawNode(foldersNode,do
c, level, lastNode, leftSide)
{
var j=0
var i=0
doc.write("<table border=0 cellspacing=0 cellpadding=0>")
doc.write("<tr><td valign = middle nowrap>")
doc.write(leftSide)
if (level>0)
if (lastNode) //'brother'×&amp;Oacute;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;Ecirc;&amp;yacute;×é&amp;Ouml;&amp;ETH;&amp;Oacute;&amp;ETH;·&amp;ntilde;&amp;ETH;&amp;Ouml;&amp;micro;&amp;Uuml;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;
{
doc.write("<img src='lastnode.gif' width=16 height=22>")
leftSide = leftSide + "<img src='blank.gif' width=16 height=22>"
}
else
{
doc.write("<img src='node.gif' width=16 height=22>")
leftSide = leftSide + "<img src='vertline.gif' width=16 height=22>"
}
displayIconAndLabel(foldersNode,do
c)
doc.write("</table>")
if (foldersNode.length > 4 &amp;&amp;
foldersNode[0]) //&amp;Oacute;&amp;ETH;&amp;cedil;ü&amp;micro;&amp;Iacute;&amp;sup2;&amp;atilde;&amp;micro;&amp;Auml;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;ordm;&amp;Iacute;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;frac14;&amp;ETH;&amp;Otilde;&amp;sup1;&amp;iquest;&amp;ordf;×&amp;Aring;
{
if (!foldersNode[2])//&amp;acute;&amp;oslash;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;frac14;&amp;ETH;&amp;micro;&amp;Auml;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;frac14;&amp;ETH;
{
level=level+1
for (i=4;
i<foldersNode.length;i++)
if (i==foldersNode.length-1)
redrawNode(foldersNode,do
c, level, 1, leftSide)
else
redrawNode(foldersNode,do
c, level, 0, leftSide)
}
else
//&amp;acute;&amp;oslash;&amp;Icirc;&amp;Auml;&amp;micro;&amp;micro;&amp;micro;&amp;Auml;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;frac14;&amp;ETH;
{
for (i=4;
i<foldersNode.length;i++)
{
doc.write("<table border=0 cellspacing=0 cellpadding=0 valign=center>")
doc.write("<tr><td nowrap>")
doc.write(leftSide)
if (i==foldersNode.length - 1)
doc.write("<img src='lastnode.gif' width=16 height=22>")
else
doc.write("<img src='node.gif' width=16 height=22>")
doc.write(foldersNode)
doc.write("</table>")
}
}
}
}
function displayIconAndLabel(foldersNode,do
c)
{
doc.write("<A href='javascript:top.openBranch(/"" + foldersNode[3] + "/")'><img src=")
if (foldersNode[1])
doc.write("openfolder.gif width=24 height=22 border=noborder></a>")
else
doc.write("closedfolder.gif width=24 height=22 border=noborder></a>")
doc.write("<td valign=middle align=left nowrap>")
doc.write("<font style='font-size:9pt;font-family:&amp;Euml;&amp;Icirc;&amp;Igrave;&amp;aring;'>"+foldersNode[3]+"</font>")
}
//&amp;Ecirc;÷&amp;Ecirc;&amp;Otilde;&amp;Acirc;&amp;pound;&amp;Ecirc;±&amp;micro;÷&amp;Oacute;&amp;Atilde;&amp;micro;&amp;Auml;&amp;ordm;&amp;macr;&amp;Ecirc;&amp;yacute;
//&amp;micro;±&amp;cedil;&amp;cedil;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;sup1;&amp;Oslash;±&amp;Otilde;,&amp;AElig;&amp;auml;&amp;Euml;ù&amp;Oacute;&amp;ETH;&amp;micro;&amp;Auml;×&amp;Oacute;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;&amp;Ograve;&amp;sup2;&amp;para;&amp;frac14;±&amp;Otilde;&amp;ordm;&amp;Iuml;
function closeFolders(foldersNode)
{
var i=0
if (!foldersNode[2])
{
for (i=4;
i< foldersNode.length;
i++)
closeFolders(foldersNode)
}
foldersNode[0] = 0
foldersNode[1] = 0
}
//&amp;Ecirc;&amp;Otilde;&amp;Acirc;&amp;pound;&amp;frac12;&amp;Uacute;&amp;micro;&amp;atilde;
function clickOnFolderRec(foldersNode, folderName)
{
var i=0
if (foldersNode[3] == folderName)
{
if (foldersNode[0])
closeFolders(foldersNode)
else
{
foldersNode[0] = 1
foldersNode[1] = 1
}
}
else
{
if (!foldersNode[2])
for (i=4;
i< foldersNode.length;
i++)
clickOnFolderRec(foldersNode, folderName)
}
}
//&amp;acute;ò&amp;iquest;&amp;ordf;·&amp;Ouml;&amp;Ouml;§
function openBranch(branchName)
{
clickOnFolderRec(foldersTree, branchName)
if (branchName=="Start folder" &amp;&amp;
foldersTree[0]==0)
top.folderFrame.location="basefolder.htm"
timeOutId = setTimeout("redrawTree()",100)
}
//&amp;Ograve;&amp;sup3;&amp;Atilde;&amp;aelig;&amp;Ocirc;&amp;Oslash;&amp;Egrave;&amp;euml;&amp;Ecirc;±&amp;micro;&amp;Auml;&amp;sup3;&amp;otilde;&amp;Ecirc;&amp;frac14;&amp;raquo;&amp;macr;
function initializeTree()
{
generateTree()
redrawTree()
}
var foldersTree = 0
var timeOutId = 0
generateTree()
-->
</script>
</HEAD>
<FRAMESET cols="200,*" onLoad='initializeTree()'>
<FRAME src="BASETREE.HTM" name="treeFrame">
<FRAME SRC="basefolder.htm" name="folderFrame">
</FRAMESET><noframes></noframes>
</HTML>
 
人家这么热心,楼主怎么一点反应都没有?
本来也想贴一段代码,可是一看日期,算了!
 
贴一些java application中应用Tree的code吧
谢谢
要分没问题
 
其实我也才刚学,要贴也是书上的例子。
不过我觉得很奇怪,这个好像不难啊,
就像用最基本的JButton等等,道理一摸一样!
贴出来不要笑我菜,sorry
代码:
//JTree数据树
JTree()
JTree(TreeModel model)
JTree(Hashtable value)		// 建立节点Value,不显示根节点的数据树
JTree(Object[] value)		// 建立节点Value,不显示根节点的数据树
JTree(Vector value)			// 建立节点Value,不显示根节点的数据树
JTree(TreeNode root)		// 建立一root为根节点的数据树
boolean isEditable()		
void setEditable(boolean b)
boolean isRootVisible()		// 表示数据树是否显示根节点
boolean setRootVisible(boolean b)	
int getRowHeight()
void setRowHeight(int rowh)
boolean getShowsRootHandles()	// 表示根节点前是否显示代表展开或关闭的图标,预设为false
boolean setShowsRootHandles()
int getRowCount()			// 返回显示的行数,一个节点为一行
int getSelectionCount()		// 返回被选择的节点数
//例如
import javax.swing.*;
                        
import javax.swing.tree.*;
                               //载入 javax.swing.tree.*
public class ch8_5 extends JFrame 
{  
	public static void main(String args[])
	{
		ch8_5 frame1 = new ch8_5();
		frame1.setTitle("数据树");
		frame1.setSize(200,200);
   
		frame1.setVisible(true);
	}
	public ch8_5()                          
	{
		DefaultMutableTreeNode node1,node2,node3;
		DefaultMutableTreeNode root = new DefaultMutableTreeNode("荣钦科技");
		/* 建立根节点 */
		root.add(node1 = new DefaultMutableTreeNode("图书部"));
 //增加 node1 到 root 下
		/* 建立 node1 及其下子节点 */
		node1.add(new DefaultMutableTreeNode("郭小桢"));
		node1.add(new DefaultMutableTreeNode("张小智"));
		node1.add(new DefaultMutableTreeNode("李小承"));
		root.add(node2 = new DefaultMutableTreeNode("程序部"));
 //增加 node2 到 root 下
		/* 建立 node2 及其下子节点 */
		node2.add(new DefaultMutableTreeNode("周大相"));
		root.add(node3 = new DefaultMutableTreeNode("美工部"));
 //增加 node3 到 root 下
		/* 建立 node3 及其下子节点 */
		node3.add(new DefaultMutableTreeNode("陈阿贤"));
		JTree tree = new JTree(root);
                           //建立 Jtree 对象 tree
		tree.setShowsRootHandles(true);
                         //显示 root 的展开关闭图标
		tree.setEditable(true);
                                 //设定 tree 为可编辑
		getContentPane().add(new JScrollPane(tree));
           
	}
}
 
现在怎么默认换行了??
 
我有做过,不过有问题,试试看!
谢谢!
 
后退
顶部