Javafx 如何从控制器类填充fxml表视图

Javafx 如何从控制器类填充fxml表视图,javafx,fxml,Javafx,Fxml,我想用控制器中的数据填充TableView,但我不知道为什么我的解决方案不起作用 在fxml中,我要填充的元素如下所示: <TableView fx:id="t" layoutX="0" layoutY="30" prefHeight="400" prefWidth="600"> <columns> <TableColumn prefWidth="200" text="name" fx:id="name" />

我想用控制器中的数据填充TableView,但我不知道为什么我的解决方案不起作用

在fxml中,我要填充的元素如下所示:

      <TableView fx:id="t" layoutX="0" layoutY="30" prefHeight="400" prefWidth="600">
        <columns>
          <TableColumn prefWidth="200" text="name" fx:id="name" />
          <TableColumn prefWidth="200" text="adress" fx:id="adress" />
            <TableColumn prefWidth="200" text="phone" fx:id="phone" />
        </columns>
      </TableView>
结果是:

请(您很接近,缺少完整的fxml和应用程序:)说:从您的代码片段来看,您似乎没有使用cellValueFactory配置列。与您的问题无关:请学习java命名约定并坚持它们。哦,只是看看:你的数据类的api是病态的-看看教程/课程手册,看看访问属性及其值的传统方式(提示:通常它们不是作为参数传递的)Hi@Ramprasath Selvam谢谢你的回答,我对javafx和fxml不熟悉,英语不是我的母语,你能推荐一些图图/课程来学习这门课吗basics@yassine看看这个链接格伦德尔,非常感谢你,这正是我要找的。
public class controler implements  Initializable  {
    public Pane p;
    public MenuBar menu;
    @FXML public TableView<User> t;
    @FXML public TableColumn<User, String> name;
    @FXML public TableColumn<User, String> adress;
    @FXML public TableColumn<User, String> phone;
    @Override
    public void initialize(URL arg0, ResourceBundle arg1) {
        FXCollections.observableArrayList(new User("zaza","zaza","zaza"));
          menu.prefWidthProperty().bind(p.widthProperty());
          t.getItems().add(new User("John","NewYork","+16879060"));
          t.setEditable(true);
          t.setVisible(true);

    }
}
public class User {
    private SimpleStringProperty name;
    private SimpleStringProperty adress;
    private SimpleStringProperty phone;

    public String getName() {
        return name.get();
    }
    public void setName(SimpleStringProperty name) {
        this.name = name;
    }
    public String getAdress() {
        return adress.get();
    }
    public void setAdress(SimpleStringProperty adress) {
        this.adress = adress;
    }
    public String getPhone() {
        return phone.get();
    }
    public void setPhone(SimpleStringProperty phone) {
        this.phone = phone;
    }
    public User(String name, String adress, String phone) {
        super();
        this.name = new SimpleStringProperty(name);
        this.adress = new SimpleStringProperty(adress);
        this.phone = new SimpleStringProperty(phone);
    }

}