填充Javafx TableView

发布于 2025-02-06 10:07:37 字数 1635 浏览 0 评论 0原文

我在tableview中使用的一列有问题。
最初,此列用于显示我拥有的一种数据:

usageTab.setCellValueFactory(new PropertyValueFactory<ResearchData, String>("lusage"));

我想更改此列中显示的数据,因此我更改了FXML文件中的列名,然后写了这篇文章:

systemeTab.setCellValueFactory(new PropertyValueFactory<ResearchData, String>("lSysteme"));

我的ResearchData类是这样编码的:

public class ResearchData {
    public int getRang() {
        return rang;
    }
    public void setRang(int rang) {
        this.rang = rang;
    public String getLusage() {
        return lusage;
    }
    public void setLusage(String lusage) {
        this.lusage = lusage;
    }
    public String getlSysteme() {
        return lSysteme;
    }
    public void setlSysteme(String lSysteme) {
        this.lSysteme = lSysteme;
    private int rang;
    private String lusage;
    private String lSysteme;


    public ResearchData(int rang, 
            String lusage, 
            String lSysteme) {
        this.rang= rang;
        this.lusage= lusage;
        this.lSysteme=lSysteme;
    }
}

(我只保留了响应,Lusage和Lsysteme,但是我还有很多其他类似的变量)。

当我启动该程序时,在表观视图中,每个列都正确显示了Systeme One除外,并且我有此错误消息:

juin 10, 2022 10:55:35 AM javafx.scene.control.cell.PropertyValueFactory getCellDataReflectively
WARNING: Can not retrieve property 'lSysteme' in PropertyValueFactory: javafx.scene.control.cell.PropertyValueFactory@106b20b1 with provided class type: class codejava.ResearchData
java.lang.IllegalStateException: Cannot read from unreadable property lSysteme

我可以使用Getter打印系统数据,并且对应于我编写的一条。

你能帮助我吗?

I have a problem with one of the columns I use in a tableview.
This column was initially used to show one type of data I have :

usageTab.setCellValueFactory(new PropertyValueFactory<ResearchData, String>("lusage"));

I wanted to change the data that is shown in this column, so I changed the column name in my FXML file and I wrote this :

systemeTab.setCellValueFactory(new PropertyValueFactory<ResearchData, String>("lSysteme"));

My ResearchData class is coded like this :

public class ResearchData {
    public int getRang() {
        return rang;
    }
    public void setRang(int rang) {
        this.rang = rang;
    public String getLusage() {
        return lusage;
    }
    public void setLusage(String lusage) {
        this.lusage = lusage;
    }
    public String getlSysteme() {
        return lSysteme;
    }
    public void setlSysteme(String lSysteme) {
        this.lSysteme = lSysteme;
    private int rang;
    private String lusage;
    private String lSysteme;


    public ResearchData(int rang, 
            String lusage, 
            String lSysteme) {
        this.rang= rang;
        this.lusage= lusage;
        this.lSysteme=lSysteme;
    }
}

(I only kept rang, lusage and lSysteme, but I have a lot of other variables written exactly like this).

When I launch the program, in the tableview, every column is displayed correctly except for the Systeme one, and I have this error message :

juin 10, 2022 10:55:35 AM javafx.scene.control.cell.PropertyValueFactory getCellDataReflectively
WARNING: Can not retrieve property 'lSysteme' in PropertyValueFactory: javafx.scene.control.cell.PropertyValueFactory@106b20b1 with provided class type: class codejava.ResearchData
java.lang.IllegalStateException: Cannot read from unreadable property lSysteme

I can print the Systeme data with the getter, and it corresponds to the one I have written.

Can you help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抹茶夏天i‖ 2025-02-13 10:07:38

我只需要

systemeTab.setCellValueFactory(new PropertyValueFactory<ResearchData, String>("lSysteme"));

替换

systemeTab.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getlSysteme()));

I just had to replace

systemeTab.setCellValueFactory(new PropertyValueFactory<ResearchData, String>("lSysteme"));

with

systemeTab.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getlSysteme()));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文