2 つのクラスがあります。1 つは と呼ばれStudent、もう 1 つは と呼ばれCourseます。簡単な登録システムのシミュレーションをしたいと思います。
私Studentのクラス部分には次の形式があります。
class Student
{
private String id,
private Course[] listOfCourses;
private int numCourse;
//accesing methods
public registration(Course course){
listOfCourses[numCourse]=course;
numCourse++;
}
public Course[] getCourse(){
return listOfCourses;
}
}
Courseクラスの形式は次のとおりです。
class Course
{
String id, String courseName;
//constructor
//accesing methods
}
Java Swingで作成したフォームでボタンを押すと、特定の学生が登録した科目の内容をjTableに表示したい。私は次のことを試しましたが、結果はまったくありませんでした:
Student e=new Student();
Course d[]=new Course[4];
d=e.getCourses(); //to receive the array of Courses from the Student class
for (int i=0;i<d.length;i++){
jTable2.setValueAt(estLista[i].getName(), i, 0);
}
どうすればそれができますか?Courseクラスに格納されている配列の内容をActionEventボタンの に取得する方法があるということですか?