0
javafxにテーブルビューを用意しています。アイデアは、私のコースのクラスでは、私は異種のクラスCourseIdである複合主キーを持っていることです。私はCourseIdクラスに存在するコースノーをtableviewの1列に追加したいが、それを得る方法は分かりません。javafxでテーブルビューにデータを入力する
マイコースクラス:
package com.licenta.ascourses.ui.model;
import java.io.Serializable;
public class Course implements Serializable {
private CourseId idCourse = new CourseId();
private int year;
private int semester;
private String discipline;
private String professor;
public Course() {
}
public Course(CourseId idCourse, int year, int semester) {
super();
this.idCourse = idCourse;
this.year = year;
this.semester = semester;
}
public Course(CourseId idCourse, int year, int semester, String discipline, String professor) {
this.idCourse=idCourse;
this.year = year;
this.semester = semester;
this.discipline = discipline;
this.professor = professor;
}
public CourseId getIdCourse() {
return idCourse;
}
public void setIdCourse(CourseId idCourse) {
this.idCourse = idCourse;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getSemester() {
return semester;
}
public void setSemester(int semester) {
this.semester = semester;
}
public String getDiscipline() {
return discipline;
}
public void setDiscipline(String discipline) {
this.discipline = discipline;
}
public String getProfessor() {
return professor;
}
public void setProfessor(String professor) {
this.professor = professor;
}
}
マイcourseIdクラス:
package com.licenta.ascourses.ui.model;
import java.io.Serializable;
public class CourseId implements Serializable {
private int idDiscipline;
private int idProfessor;
private int courseNo;
public CourseId() {
}
public CourseId(int idDiscipline, int idProfessor, int courseNo) {
super();
this.idDiscipline = idDiscipline;
this.idProfessor = idProfessor;
this.courseNo = courseNo;
}
public int getIdDiscipline() {
return idDiscipline;
}
public void setIdDiscipline(int idDiscipline) {
this.idDiscipline = idDiscipline;
}
public int getIdProfessor() {
return idProfessor;
}
public void setIdProfessor(int idProfessor) {
this.idProfessor = idProfessor;
}
public int getCourseNo() {
return courseNo;
}
public void setCourseNo(int courseNo) {
this.courseNo = courseNo;
}
public boolean equals(Object o) {
return true;
}
public int hashCode() {
return 1;
}
}
columnNumarCurs.setCellValueFactory(new PropertyValueFactory<Course, Integer>(""));
columnAn.setCellValueFactory(new PropertyValueFactory<Course, Integer>("year"));
columnSemestru.setCellValueFactory(new PropertyValueFactory<Course, Integer>("semester"));
columnDisciplina.setCellValueFactory(new PropertyValueFactory<Course, String>("discipline"));
columnProfesor.setCellValueFactory(new PropertyValueFactory<Course, String>("professor"));