0
javafx에 질문이 있습니다. bib 파일로 작업하는 프로젝트가 있습니다. 테이블 뷰에 클래스 데이터 (Entry)를 삽입하려고 할 때 문제가 발생합니다. 그러나 여전히 tableview에서는 비어 있습니다. 작업은 이름을 입력하고 bib 파일에서 검색 한 다음 결과를 표보기에 표시합니다. 감사 The gui imageJavafx 어떻게 데이터를 테이블 뷰에 삽입 할 수 있습니까?
는 내가있는 tableview 채우기 클래스를
public class Entry implements Comparable<Entry>{ public static final int ignoreOrder=-1; public static final int OrderByName=0; public static final int OrderByTitle=1; public static final int OrderByYear=2; private String name; private String title=""; private String year="0"; private int order=OrderByName; public int getOrder() { return order; } public void setOrder(int order) { this.order = order; } public Entry(String name){ this.name=name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getYear() { return year; } public void setYear(String year) { this.year = year; } }
을 가지고 있지만, 여전히 빈. 그런 다음 당신은 단순히 그렇지 않으면 당신은 조회 할
Col_Title.setCellValueFactory(new PropertyValueFactory<Row, String>("title"));
을 추가 할 수 있습니다 private SimpleStringProperty title
에 예를 private String title;
에 대한 SimpleStringProperty
에 String
에서 모든 필드를 변경할 수있는 경우
@FXML
private TableView<Entry> table_id;
@FXML
private TableColumn<Entry, String> Col_BKey;
@FXML
private TableColumn<Entry, String> Col_counts;
@FXML
private TableColumn<Entry, String> Col_EntryType;
@FXML
private TableColumn<Entry, String> Col_Title;
@FXML
private TableColumn<Entry, String> Col_Year;
@FXML
private TableColumn<Entry, String> Col_Booktitle;
@FXML
private TableColumn<Entry, String> Col_Author;
public void loadFile(ActionEvent event){
int orderModel=0;
if(title_radio.isSelected()){
orderModel=1;
}else if(year_radio.isSelected()){
orderModel=2;
}
ReadingProcessor readingProcessor=new ReadingProcessor(new OrderedLinkedList(orderModel));
entryList=readingProcessor.read(filePath);
}
public void SelectOKAction(ActionEvent event) {
String searchStr=select_text.getText();
if(searchStr==null||searchStr.trim().equals("")){
AlertBox.display("Wrong", "Please enter entry's name");
return;
}
Entry entry=entryList.search(searchStr);
if(entry==null){//NOT FOOUND
AlertBox.display("Wrong", "Entry not exists!");
}
ObservableList<Entry> list = FXCollections.observableArrayList(entry);
table_id.setItems(list);
}
공동 de는 비어있는 목록을 만들고 테이블의 백업 목록으로 설정했습니다. 실제로 데이터를 만들고 목록에 추가하는 위치는 어디입니까? –
내 코드를 편집했습니다. 나는 bib 파일을 읽고 파일에서 항목을 검색하기 위해 텍스트에 이름을 입력합니다. 이 항목을 tableview에 삽입하고 싶지만 어떻게해야할지 모르겠다. @ James_D에게 감사합니다. – JhihweiLi