PDA

浏览完整版本 : 十万火急,请教一个java问题!!谢谢



kkundcc
09-03-25, 03:33
左边是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");
}
}
}

请问到底该如何实现这个功能啊....急死了.....:26:

Turing
09-03-25, 21:07
左边是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");
}
}
}

请问到底该如何实现这个功能啊....急死了.....:26:
这算是简单的JAVA编程了,如果你人在维也纳,我可以有偿教你,不会不收你学费!