如果我将它设置为相同的值,则在我的 bean 上调用 firePropteryChange() 不会执行任何操作

发布于 2024-10-10 01:02:46 字数 439 浏览 0 评论 0原文

我有一个带有“fftLength”字段的bean。当我调用时,

    public void setfftLength(String fftLength) 
{
    String oldfftLength = this.fftLength;
    this.fftLength = fftLength;
    changeSupport.firePropertyChange("fftLength", oldfftLength, fftLength);
}

我希望我的 GUI 对象能够反映更改。我使用 JGoodies Binding 绑定它。

问题是我有一个奇怪的极端情况,我需要使用相同的值调用设置器,因为我的模型和视图不同步。当我使用相同的值调用设置器时,什么也没有发生,我猜这是因为通常这将是一个浪费的操作。即使我设置相同的值,有没有办法强制 bean 更新?

I have a bean with a field "fftLength". When I call

    public void setfftLength(String fftLength) 
{
    String oldfftLength = this.fftLength;
    this.fftLength = fftLength;
    changeSupport.firePropertyChange("fftLength", oldfftLength, fftLength);
}

I expect my GUI object to reflect the change. I bind it with using JGoodies Binding.

The problem is that I have this weird corner case where I need to call the setter with the same value because my model and view go out of sync. When I call the setter with the same value nothing happens, which I guess is because usually this would be a wasted operation. Is there a way to force the bean to update even though I am setting the same value?

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

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

发布评论

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

评论(1

深海少女心 2024-10-17 01:02:46

正确的答案是我永远不应该让模型和视图不同步。我和另一位工程师讨论过,这就是结论。即使我设置相同的值,也绝对没有办法强制 bean 更新。我通过在代码中考虑更高的几层来解决我的问题。我有一个操作顺序问题困扰着我,直到我与另一位工程师交谈后我才发现它:)

The correct is answer is that I should never let me model and view get out of sync. I talked about it with another engineer and that was the conclusion. There definitely is not a way to force the bean to update even though I am setting the same value. I fixed my problem by thinking a couple layers higher above in my code. I had an order of operation problem that was screwing me and I just didn't see it till after I spoke with the other engineer :)

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