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