好的,所以我是新手,我一直在寻找两周的时间来尝试将一个SQL结果集打印到由JavaFX Scene Builder制作的TableView上.我可以使用System.out.println打印我的结果集并且数据是正确的,但是当我尝试将它放入List时,我的tableview显示一列为0,另一列为空.我正在尝试打印List(println),但是我得到了对象指针(?)而不是数据,所以我无法看到我是否正确地从ResultSet传递到List.
任何帮助将不胜感激......我想了解这个概念,而不仅仅是得到答案.
这是我的控制器代码:
public class TesterUIController implements Initializable {
@FXML
private TableView<dataClass> Table;
@FXML
private Button TestButton;
@FXML
private TableColumn<dataClass, Integer> colKey;
@FXML
private TableColumn<dataClass, String> colSalesNo;
public static void main (String[] args) {
System.out.println("Main has run");
}
/**
*
* @param fxmlFileLocation
* @param resources
*/
@Override
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
TestButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Button Pressed");
colKey.setCellValueFactory(new PropertyValueFactory<dataClass, Integer>("Key"));
colSalesNo.setCellValueFactory(new PropertyValueFactory<dataClass, String>("SalesNo"));
Table.getItems().setAll(gobbledyGook());
}
} );
}
/* …Run Code Online (Sandbox Code Playgroud)