Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Swixml2中更新绑定_Java_Swing_Swixml - Fatal编程技术网

Java 在Swixml2中更新绑定

Java 在Swixml2中更新绑定,java,swing,swixml,Java,Swing,Swixml,我有一个用xml定义的对话框,它与对话框对应bean上的属性绑定 : <label text="Project Files Location"/> <textfield id="tfProjectLocation" bindWith="projectLocation"/> <button label="Browse" action="actionBrowse"/> : : : 当我从bean中更新属性的值时(例如通过操作),UI不会用新值更新。1)Swin

我有一个用xml定义的对话框,它与对话框对应bean上的属性绑定

:
<label text="Project Files Location"/>
<textfield id="tfProjectLocation" bindWith="projectLocation"/>
<button label="Browse" action="actionBrowse"/>
:
:
:
当我从bean中更新属性的值时(例如通过操作),UI不会用新值更新。

1)Swing是单线程的,所有更改都必须在EDT()上完成

2) 如果要更新UI, -如果没有EDT, -从后台任务更新摄像机 -没有来自(特别是来自或)的事件

a) 您必须包装到invokeLater()中


b) 不确定,但大多数方法都应该与UI/Look&Feel相关,然后必须调用
SwingUtilities.updateComponentTreeUI
()

找到了答案。我需要向bean上的
PropertyChangeListener
发送一个
PropertyChangeEvent

projectLocation = fc.getSelectedFile().getPath();
PropertyChangeEvent pce = new PropertyChangeEvent(this,
    "projectLocation", projectLocation, fc.getSelectedFile().getPath());
PropertyChangeListener[] p = getPropertyChangeListeners();
p[0].propertyChange(pce);

您能否验证
操作
操作浏览
,是否已使用
浏览
按钮注册?正在调用操作浏览。它将创建一个文件选择器对话框,返回分配给属性projectLocation的路径。在代码中,我可以看到projectLocation更改为新值,但文本字段没有更新以反映它。因此,
bindWith
应该实现这一点吗?这是我所期望的,但我需要调度PropertyChangeEvent。见我自己:(回答如下。