私の最終的なプロジェクトで初めてJavafxを使用しています。TabPaneにTableViewを表示する際に問題があります。TableView TabPaneを表示
私はTableViewを作成し、それを塗りつぶしてSceneBuilderを使って作成したTableViewと関連付けるためにinitialize()という名前の関数を持っています(私のコントローラのTableViewに同じFx:idを指定しました)関数はTabsとTabPaneを作成し、最後にTabPaneを返します。 私のメインコントローラの中でこの関数を呼び出しましたが、何も表示しません。
@FXML public TabPane initialize()
{
//Stage stage = new Stage();
//BorderPane root = new BorderPane();
TabPane tp = new TabPane();
Tab ose = new Tab("Liste OS&E");
ose.setClosable(false);
TableView <ose> osetable = new TableView<ose>();
TableColumn<ose, String> descolumn = new TableColumn<ose, String>("Designation");
TableColumn<ose, String> articlecolumn = new TableColumn<ose, String>("Article");
TableColumn<ose, String> fourcolumn = new TableColumn<ose, String>("Fournisseur");
descolumn.setCellValueFactory(
new PropertyValueFactory<ose, String>("designation"));
articlecolumn.setCellValueFactory(
new PropertyValueFactory<ose, String>("article"));
fourcolumn.setCellValueFactory(
new PropertyValueFactory<ose, String>("fournisseur"));
osetable.setItems(getOSE());
osetable.getColumns().addAll(descolumn,articlecolumn,fourcolumn);
ose.setContent(osetable);
tp.getTabs().add(ose);
return tp ;
}
と私は自分のページを作成し、それを呼び出しどのようにこの:
else if (e.getSource()== gestionprojet)
{
FXMLLoader loader = new FXMLLoader(getClass().getResource("../V/Gestionprjt.fxml"));
loader.setController(this);
stage.setResizable(false);
stage.setTitle("Gestion de projet - Sofitel Tamuda Bay Beach & Resort");
Image icon = new Image(getClass().getResourceAsStream("../V/logo-Sofitel.png"));
stage.getIcons().add(icon);
BorderPane root = new BorderPane();
root.getChildren().add(initialize());
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
君たちは私のコードで間違って何を教えてもらえますか? ありがとうございます
非常にgratefull、ありがとうございました! –