javafx tableview不会显示来自数据库的数据
`public class packList` {
Stage primaryStage;
私有TableView tbl = new TableView();
private TableColumn pSerial = new TableColumn<>("序列号");
private TableColumn pName = new TableColumn<>(" Package Name");
private TableColumn<Packaged, String> pSpeed = new TableColumn<>("Speed");
private TableColumn<Packaged, String> pMonthlyFee = new TableColumn<>("Monthly Fee");
private TableColumn<Packaged, String> pConnection = new TableColumn<>("Connection Fee");
private TableColumn<Packaged, String> pOther = new TableColumn<>("Others");
private TableColumn<Packaged, String> pView = new TableColumn<>("View");
private TableColumn pEdit = new TableColumn&lt;&gt;(&#34; Edit&#34;);
private TableColumn pDelete = new TableColumn&lt;&gt;(&#34; Delete&#34;);
private Packaged packaged = new Packaged();
private PackageController packageController = new PackageController();
private ArrayList<Packaged> packagedList = new ArrayList<>();
private ObservableList<Packaged> ps;
public packList(Stage stage) {
this.primaryStage = stage;
this.primaryStage.show();
this.primaryStage.setScene(AllpackList());
}
@SuppressWarnings("unchecked")
public Scene AllpackLis() {
StackPane mainPane = new StackPane();
mainPane.setAlignment(Pos.TOP_LEFT);
StackPane pane = new StackPane();
pane.setAlignment(Pos.TOP_LEFT);
// empName.prefWidthProperty().bind(tbl.widthProperty().multiply(10));
packagedList = packageController.getAllPackage();
ps = FXCollections.observableArrayList(packagedList);
pSerial.setCellValueFactory(new PropertyValueFactory<>("pkg_id"));
pName.setCellValueFactory(new PropertyValueFactory<>("pkg_name"));
pSpeed.setCellValueFactory(new PropertyValueFactory<>("speed"));
pMonthlyFee.setCellValueFactory(new PropertyValueFactory<>("mFee"));
pView.setCellValueFactory(new PropertyValueFactory<>("view"));
pEdit.setCellValueFactory(new PropertyValueFactory<>("edit"));
pDelete.setCellValueFactory(new PropertyValueFactory<>("delete"));
tbl.setItems(ps);
StackPane.setMargin(tbl, new Insets(15, 15, 15, 15));
tbl.getColumns().addAll(pSerial, pName, pSpeed, pMonthlyFee, pView, pEdit, pDelete);
pane.getChildren().addAll(tbl);
// StackPane.setMargin(pane, new Insets(15, 15, 15, 15));
pane.getStyleClass().add("pane");
mainPane.getChildren().addAll(pane);
return Common.returnScene(mainPane);
}
}
and java class is
:
公共课&#39;打包&#39; {
private int pkgId;
private String pkgName;
private String pkgSpeed;
private String pkgCFee;
private String pkgMFee;
public int getPkgId() {
return pkgId;
}
public void setPkgId(int pkgId) {
this.pkgId = pkgId;
}
public String getPkgName() {
return pkgName;
}
public void setPkgName(String pkgName) {
this.pkgName = pkgName;
}
public String getPkgSpeed() {
return pkgSpeed;
}
public void setPkgSpeed(String pkgSpeed) {
this.pkgSpeed = pkgSpeed;
}
public String getPkgCFee() {
return pkgCFee;
}
public void setPkgCFee(String pkgCFee) {
this.pkgCFee = pkgCFee;
}
public String getPkgMFee() {
return pkgMFee;
}
public void setPkgMFee(String pkgMFee) {
this.pkgMFee = pkgMFee;
}
}