简体   繁体   English

JGoodies绑定不会让我重新绘制我的JComponent

[英]JGoodies binding will not let me repaint my JComponent

I have a bound JTextField and a seperate graph made from a JComponent. 我有一个绑定的JTextField和一个由JComponent制成的单独图形。 When I drag on my graph, a marker should update and the bound JTextField should show its coordinates as it is being dragged. 当我在图形上拖动时,标记应更新,并且绑定的JTextField在拖动时应显示其坐标。 When I am binding, the graph will not repaint until I finish dragging. 当我绑定时,在完成拖动之前,图形不会重新绘制。 When I turn off the binding, my graph repaints as a I drag. 当我关闭绑定时,图形会随着拖动而重新绘制。 I do not understand why JGoodies is blocking out my repaint calls while I drag. 我不明白为什么JGoodies在拖动时会阻止我的重画调用。 Does anybody know why this could happen? 有人知道为什么会这样吗?

My code looks like: 我的代码如下:

public void dragMarker()
{
    ...some code...
    firePropertyChange("propertyName", oldValue, newValue);
    myJComponent.refresh();
}

Something is going on in JGoodies that I cannot figure out. 我无法弄清楚JGoodies中发生了什么。 It should repaint after the binding call completes. 绑定调用完成后,它应该重新绘制。

Also, I was just reading that Swing can collapse multiple calls to repaint into one call. 另外,我只是在读Swing可以折叠多个调用以将其重新绘制成一个调用。 Could that be happening to me? 那会发生在我身上吗? My repaint calls are just being collapsed into one call at the end? 我的重画电话只是在最后被折叠为一个电话?

My answer, which I don't find perfect satisfaction with, is that I launch a swingworker thread with a scheduled executor at a rate of .3 seconds which runs the firePropertyChangeListeners and updates JGoodies bound code. 我没有完全满意的答案是,我以0.3秒的速度启动了一个带有调度执行程序的swingworker线程,该线程运行firePropertyChangeListeners并更新JGoodies绑定的代码。 This means the updates are choppy, but at least the drawing code is almost perfectly smooth. 这意味着更新比较不稳定,但是至少绘图代码几乎完美流畅。 It boggles my mind that this problem occurs. 令我感到困惑的是,此问题发生了。 This was the best I could do... 这是我能做的最好的...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM