左边是jtree,右边是jeditorpane,希望实现点击jtree的节点在右边显示这个节点的名字
比如点击jtree 的一个叶子:计算机,那么在右边也显示出这个string:计算机
请问该如何实现?
contentPane = new JEditorPane();
contentPane.setEditable(false);
displayText(TreeSelectionEvent e);//这句有错!!!!
private void displayText(TreeSelectionEvent e) {
TreePath path = e.getPath();
String s = path.getLastPathComponent().toString();
if (ideaTree!= null) {
contentPane.setText("the content is: "+s);
} else {
contentPane.setText("nothing to displaythe content is");
if (Error) {
System.out.println("Attempted to display nothing");
}
}
}
请问到底该如何实现这个功能啊....急死了.....

书签