私のテーブルを作成する方法が見つからないようです。(私はそれらをseperatly見ると、私observebleListそれが動作するオブジェクト、それだけでinported私のデータを追加しないでください....私のテーブルビューにJava fxを埋め込むことはできません
This is my Controller:
package Interface;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
public class ControllerForFinalPoint implements Initializable {
String id ;
String x ;
String y ;
String z ;
public void exitApplication(ActionEvent exitApplication) {
Platform.exit();
}
public void intoarcere (String id, String x, String y, String z) {
this.id = id;
System.out.println(id);
this.x = x;
System.out.println(x);
this.y = y;
System.out.println(y);
this.z = z;
System.out.println(z);
}
@FXML
private TableView<MyPointFinal> tableCoord2;
@FXML
private TableColumn<MyPointFinal, String> Id;
@FXML
private TableColumn<MyPointFinal, String> X;
@FXML
private TableColumn<MyPointFinal, String> Y;
@FXML
private TableColumn<MyPointFinal, String> Z;
ObservableList<MyPointFinal> data = FXCollections.observableArrayList(
new MyPointFinal(id, x, y, z));
@Override
public void initialize(URL location, ResourceBundle resources) {
Id.setCellValueFactory(new PropertyValueFactory<MyPointFinal, String>("Id"));
Id.setCellFactory(TextFieldTableCell.forTableColumn());
X.setCellValueFactory(new PropertyValueFactory<MyPointFinal, String>("X"));
X.setCellFactory(TextFieldTableCell.forTableColumn());
Y.setCellValueFactory(new PropertyValueFactory<MyPointFinal, String>("Y"));
Y.setCellFactory(TextFieldTableCell.forTableColumn());
Z.setCellValueFactory(new PropertyValueFactory<MyPointFinal, String>("Z"));
Z.setCellFactory(TextFieldTableCell.forTableColumn());
tableCoord2.setItems(data);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Interface.ControllerForFinalPoint">
<children>
<TableView fx:id="tableCoord2" editable="true" prefHeight="558.0" prefWidth="600.0">
<columns>
<TableColumn fx:id="Id" prefWidth="75.0" text="Name" />
<TableColumn fx:id="X" prefWidth="150.0" text="X" />
<TableColumn fx:id="Y" prefWidth="150.0" text="Y" />
<TableColumn fx:id="Z" prefWidth="150.0" text="Z" />
</columns>
</TableView>
<AnchorPane prefHeight="59.0" prefWidth="700.0">
<children>
<Button layoutX="118.0" layoutY="34.0" mnemonicParsing="false" text="Save" AnchorPane.bottomAnchor="17.0" AnchorPane.leftAnchor="325.0" AnchorPane.rightAnchor="325.0" AnchorPane.topAnchor="17.0" />
</children>
</AnchorPane>
<AnchorPane prefHeight="38.0" prefWidth="600.0" />
</children>
</VBox>
tx、それはそれほど問題ではありませんでした。私は私のリストに入ることを奨励していた私のデータがnullであることを知りました。私は他の方向にmethodeを呼び出す必要があります。 "PS"を心に留めてくれてありがとう。 –