我有一个具有TableView附加了侦听器的应用程序,因此一旦检测到更改,它便会刷新,但事实是我正在获取java.lang.IllegalStateException: Not on FX application thread; currentThread = Smack Listener Processor (0)参见Eclipse java.lang.IllegalStateException: Not on FX application thread; currentThread = Smack Listener Processor (0) java.lang.IllegalStateException: Not on FX application thread; currentThread = Smack Listener Processor (0) 。 这是我的代码:
/**
* This function resets the pagination pagecount
*/
public void resetPage() {
try {
System.out.println("RESET");
int tamRoster = this.loginManager.getRosterService().getRosterList().size();
paginationContactos.setPageCount((int)(Math.ceil(tamRoster*1.0/limit.get())));
int tamEnviados = this.loginManager.getRosterService().getEnviadasList().size();
paginationEnviadas.setPageCount((int)(Math.ceil(tamEnviados*1.0/limit.get())));
int tamRecibidas = this.loginManager.getRosterService().getRecibidasList().size();
paginationRecibidas.setPageCount((int)(Math.ceil(tamRecibidas*1.0/limit.get())));
} catch (Exception e) {
e.printStackTrace();
}
}
public void doSomething () {
this.loginManager.getRosterService().getRosterList().addListener(new ListChangeListener() {
@Override
public void onChanged(
javafx.collections.ListChangeListener.Change extends RosterDTO> c) {
// TODO Auto-generated method stub
resetPage();
while (c.next()) {
if (c.wasPermutated()) {
System.out.println("PERM");
} else if (c.wasUpdated()) {
System.out.println("UPD");
} else {
System.out.println("ELSE");
}
}
}
});
}
尽管它进入了resetPage方法,但出现了该异常。 为什么会这样呢? 我该如何解决? 提前致谢。