0
我對JavaFX非常新穎,我需要從表視圖中識別選中/選中複選框的幫助。查看我用於填充表格視圖數據的用戶界面和代碼截圖。我使用場景生成器用於創建UI如何從javafx上的tableview中獲取複選框的選定索引
代碼來初始化表視圖UI
這裏的
public void initialize(URL location, ResourceBundle resources) {
ddUrls.setItems(urls);
ddbrowserNames.setItems(browsers);
ddFrames.setItems(frames);
//testClassCl.setCellValueFactory(new PropertyValueFactory<TestSuite,String>("testClass"));
testMethodCl.setCellValueFactory(new PropertyValueFactory<TestSuite,String>("testMethod"));
testDescCl.setCellValueFactory(new PropertyValueFactory<TestSuite,String>("testDesc"));
//runModeCl.setCellValueFactory(new PropertyValueFactory<TestSuite,Boolean>("runMode"));
runModeCl.setCellFactory(column -> new CheckBoxTableCell());
table.setItems(list);
table.setEditable(true);
}
圖片的數據模型。
package com.automation.UI;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty;
公共類的TestSuite {
private SimpleStringProperty testClass;
private SimpleStringProperty testMethod;
private SimpleStringProperty testDesc;
private SimpleBooleanProperty runMode;
public TestSuite(String testClass, String testMethod, String testDesc, boolean runMode) {
this.testClass = new SimpleStringProperty(testClass);
this.testMethod = new SimpleStringProperty(testMethod);
this.testDesc = new SimpleStringProperty(testDesc);
this.runMode = new SimpleBooleanProperty(runMode);
}
public String getTestClass() {
return testClass.get();
}
public String getTestMethod() {
return testMethod.get();
}
public String getTestDesc() {
return testDesc.get();
}
public boolean getRunMode() {
return runMode.get();
}
}
我的目標是獲得描述所有選定的複選框(旁邊的檢查欄)上點擊另一個按鈕
列表什麼是「選擇複選框指數」?你的表有很多複選框,所以可能沒有一個選中的複選框,可能沒有,一個或多個複選框。請更好地解釋一下你需要的數據以及爲什麼你需要它。此外,複選框應該是用戶可編輯的,以便用戶可以點擊它們來改變它們的狀態?用戶可以通過單擊它來選擇表格中的一行(獨立於複選框),您是否在查找有關所選行或複選框的信息?還請包括您的數據模型(TestSuite類)的代碼。 – jewelsea
問題已更新... – Hashili