当前位置: 技术问答>java相关
怎么为JTree控件添加addTreeSelectionListener事件?
来源: 互联网 发布时间:2015-06-22
本文导语: 希望有高人能够给我个例子,比如一个JFrame窗口包含一个JTree,一个JButton和一个JLabel,当选择一个分枝并按下JButton后JLabel显示选中的分枝的名字,如选择一个名为leaf1的分枝,按下JButton后JLabel就显示leaf1 刚注册,只有50...
希望有高人能够给我个例子,比如一个JFrame窗口包含一个JTree,一个JButton和一个JLabel,当选择一个分枝并按下JButton后JLabel显示选中的分枝的名字,如选择一个名为leaf1的分枝,按下JButton后JLabel就显示leaf1
刚注册,只有50分,不好意思
非常感谢
bromon@163.com
qq:85326886
刚注册,只有50分,不好意思
非常感谢
bromon@163.com
qq:85326886
|
package test;
import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.util.Vector;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/
public class Frame1 extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JComboBox jComboBox1 = new JComboBox();
JTextField jTextField1 = new JTextField();
Vector vecL=new Vector();
JTree jTree1;// = new JTree();
DefaultMutableTreeNode root;
public Frame1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
/* for(int i=0;i
import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.util.Vector;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/
public class Frame1 extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JComboBox jComboBox1 = new JComboBox();
JTextField jTextField1 = new JTextField();
Vector vecL=new Vector();
JTree jTree1;// = new JTree();
DefaultMutableTreeNode root;
public Frame1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
/* for(int i=0;i