C cadwolf Unregistered / Unconfirmed GUEST, unregistred user! 2002-08-07 #1 请问在JTree的显示中,如何显出各节点之间的连线?用什么函数? 如何展开所有的节点?
O oyjing Unregistered / Unconfirmed GUEST, unregistred user! 2002-08-09 #2 显出各节点之间的连线: 使用windows界面式样 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 或 UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 在"Metal"界面样式(好象是默认的)下: tree.putClientProperty("JTree.lineStyle", "Angled");
显出各节点之间的连线: 使用windows界面式样 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 或 UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); 在"Metal"界面样式(好象是默认的)下: tree.putClientProperty("JTree.lineStyle", "Angled");
O oyjing Unregistered / Unconfirmed GUEST, unregistred user! 2002-08-09 #3 展开所有的节点 JTree jTree1; ......... jTree1.addTreeExpansionListener(new javax.swing.event.TreeExpansionListener() { public void treeExpanded(TreeExpansionEvent e) { TreePath path=e.getPath(); TreeNode node=(MutableTreeNode)path.getLastPathComponent(); Enumeration enum=node.children(); while(enum.hasMoreElements()){ path=new TreePath(((DefaultMutableTreeNode)enum.nextElement()).getPath()); jTree1.expandPath(path); } } public void treeCollapsed(TreeExpansionEvent e) { } });
展开所有的节点 JTree jTree1; ......... jTree1.addTreeExpansionListener(new javax.swing.event.TreeExpansionListener() { public void treeExpanded(TreeExpansionEvent e) { TreePath path=e.getPath(); TreeNode node=(MutableTreeNode)path.getLastPathComponent(); Enumeration enum=node.children(); while(enum.hasMoreElements()){ path=new TreePath(((DefaultMutableTreeNode)enum.nextElement()).getPath()); jTree1.expandPath(path); } } public void treeCollapsed(TreeExpansionEvent e) { } });