我正在为我的学校做练习,我需要使用Jtree并在JList中显示内容,当我显示我的树时,叶子有这些奇怪的名字pruebaswing.Schedule@2037c981或pruebaswing.Schedule@7b052786,和我不知道为什么,我使用这个Java的例子#34;如何使用树"来帮助我做树:
//This is when i create the leaf
faculty= new DefaultMutableTreeNode(faculties[i]); //i create a new node father
if (i==0){
top.add(faculty); //the father adds to the root ("top") of the tree
for (int j = 0; j < degrees.length; j++) {
//the cycle for add the leaf in to the tree top
carrer= new DefaultMutableTreeNode(new Schedule(degrees[j])); //this is when i create the leaf with a specific content of new object like the example of java
facultad.add(carrer); //this when i add the leaf on the tree
}
}
//This is the class of the object Schedule
public class Schedule{
public String carrer_name; //The name of the leaf that not displayed
DefaultListModel classes; //The List of classes
public Schedule(String degree){
carrer_name=degree;
String Ing_Civil[]={"Ladrillos", "Puentes", "Hidraulica"};
classes = new DefaultListModel();
if(degree=="Ingenieria Civil"){
for (int i = 0; i < Ing_Civil.length; i++) {
classes.addElement(Ing_Civil[i]);
}
}
}
抱歉我的英文